Skip to content

Commit

Permalink
Create new testing project for AasxServerBlazor (#303)
Browse files Browse the repository at this point in the history
* Create new testing project

* add
        <ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>

* prevent error for duplicate files
  • Loading branch information
Freezor authored Jun 24, 2024
1 parent 4aa4dad commit 579bcca
Show file tree
Hide file tree
Showing 15 changed files with 156 additions and 52 deletions.
1 change: 1 addition & 0 deletions src/AasCore.Aas3_0/AasCore.Aas3_0.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<PackageLicenseUrl>https://raw.githubusercontent.com/aas-core-works/aas-core3.0-csharp/main/LICENSE</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/aas-core-works/aas-core3.0-csharp</PackageProjectUrl>
<PackageTags>aas;asset administration shell;iiot;industry internet of things;industrie 4.0;i4.0</PackageTags>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
Expand Down
1 change: 1 addition & 0 deletions src/AasSecurity/AasSecurity.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.3.0.1-aasV3-alpha-latest</Version>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/AasSecurityTests/AasSecurityTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/AasxCsharpLibrary/AasxCsharpLibrary.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Version>0.3.0.1-aasV3-alpha-latest</Version>
<Nullable>enable</Nullable>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
</PropertyGroup>
<PropertyGroup>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
Expand Down
20 changes: 20 additions & 0 deletions src/AasxServer.sln
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger.Lib.V3.Tests", "
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger.Registry.Lib.V3.Tests", "IO.Swagger.Registry.Lib.V3.Tests\IO.Swagger.Registry.Lib.V3.Tests.csproj", "{CF9C2ABA-944C-46EB-8788-346D432321D5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AasxServerBlazorTests", "AasxServerBlazorTests\AasxServerBlazorTests.csproj", "{731275DC-5730-49FB-A721-3A39EE3F516E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -401,6 +403,24 @@ Global
{CF9C2ABA-944C-46EB-8788-346D432321D5}.Release|x64.Build.0 = Release|Any CPU
{CF9C2ABA-944C-46EB-8788-346D432321D5}.Release|x86.ActiveCfg = Release|Any CPU
{CF9C2ABA-944C-46EB-8788-346D432321D5}.Release|x86.Build.0 = Release|Any CPU
{731275DC-5730-49FB-A721-3A39EE3F516E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{731275DC-5730-49FB-A721-3A39EE3F516E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{731275DC-5730-49FB-A721-3A39EE3F516E}.Debug|x64.ActiveCfg = Debug|Any CPU
{731275DC-5730-49FB-A721-3A39EE3F516E}.Debug|x64.Build.0 = Debug|Any CPU
{731275DC-5730-49FB-A721-3A39EE3F516E}.Debug|x86.ActiveCfg = Debug|Any CPU
{731275DC-5730-49FB-A721-3A39EE3F516E}.Debug|x86.Build.0 = Debug|Any CPU
{731275DC-5730-49FB-A721-3A39EE3F516E}.DebugSlow|Any CPU.ActiveCfg = Debug|Any CPU
{731275DC-5730-49FB-A721-3A39EE3F516E}.DebugSlow|Any CPU.Build.0 = Debug|Any CPU
{731275DC-5730-49FB-A721-3A39EE3F516E}.DebugSlow|x64.ActiveCfg = Debug|Any CPU
{731275DC-5730-49FB-A721-3A39EE3F516E}.DebugSlow|x64.Build.0 = Debug|Any CPU
{731275DC-5730-49FB-A721-3A39EE3F516E}.DebugSlow|x86.ActiveCfg = Debug|Any CPU
{731275DC-5730-49FB-A721-3A39EE3F516E}.DebugSlow|x86.Build.0 = Debug|Any CPU
{731275DC-5730-49FB-A721-3A39EE3F516E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{731275DC-5730-49FB-A721-3A39EE3F516E}.Release|Any CPU.Build.0 = Release|Any CPU
{731275DC-5730-49FB-A721-3A39EE3F516E}.Release|x64.ActiveCfg = Release|Any CPU
{731275DC-5730-49FB-A721-3A39EE3F516E}.Release|x64.Build.0 = Release|Any CPU
{731275DC-5730-49FB-A721-3A39EE3F516E}.Release|x86.ActiveCfg = Release|Any CPU
{731275DC-5730-49FB-A721-3A39EE3F516E}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
1 change: 1 addition & 0 deletions src/AasxServerAspNetCore/AasxServerAspNetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Version>0.3.0.1-aasV3-alpha-latest</Version>
<RuntimeIdentifiers>linux-arm;linux-arm64;win-x64;osx-x64</RuntimeIdentifiers>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
</PropertyGroup>
<PropertyGroup>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
Expand Down
1 change: 1 addition & 0 deletions src/AasxServerBlazor/AasxServerBlazor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<SatelliteResourceLanguages>en-US;de-DE</SatelliteResourceLanguages>
<Version>0.3.0.1-aasV3-alpha-latest</Version>
<RuntimeIdentifiers>linux-arm;linux-arm64;win-x64;osx-x64</RuntimeIdentifiers>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
101 changes: 50 additions & 51 deletions src/AasxServerBlazor/BlazorServerStarter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,69 +6,68 @@
using System;
using System.IO;

namespace AasxServerBlazor
namespace AasxServerBlazor;

public static class BlazorServerStarter
{
public static class BlazorServerStarter
private const string AppSettingsFileName = "appsettings.json";
private const string KestrelEndpointsHttpUrl = "Kestrel:Endpoints:Http:Url";
private const string DefaultUrl = "http://localhost:5000";
private const char KestrelUrlSeparator = ':';

public static void Main(string[] args)
{
private const string AppSettingsFileName = "appsettings.json";
private const string KestrelEndpointsHttpUrl = "Kestrel:Endpoints:Http:Url";
private const string DefaultUrl = "http://*:5000";
private const char KestrelUrlSeparator = ':';
var config = LoadConfiguration();
var host = BuildHost(args, config);

public static void Main(string[] args)
{
var config = LoadConfiguration();
var host = BuildHost(args, config);
host.RunAsync();

host.RunAsync();
InitializeProgram(args, config);

InitializeProgram(args, config);
host.WaitForShutdownAsync();
}

host.WaitForShutdownAsync();
}
private static void InitializeProgram(string[] args, IConfiguration config)
{
Console.WriteLine($"{nameof(InitializeProgram)}");
Program.con = config;
Program.Main(args);
SecurityHelper.SecurityInit();
}

private static void InitializeProgram(string[] args, IConfiguration config)
{
Console.WriteLine($"{nameof(InitializeProgram)}");
Program.con = config;
Program.Main(args);
SecurityHelper.SecurityInit();
}
private static IHost BuildHost(string[] args, IConfiguration config)
{
Console.WriteLine($"{nameof(BuildHost)} with {config}");
var hostBuilder = CreateHostBuilder(args, config);
return hostBuilder.Build();
}

private static IHost BuildHost(string[] args, IConfiguration config)
private static IHostBuilder CreateHostBuilder(string[] args, IConfiguration config)
{
var url = config[KestrelEndpointsHttpUrl]?.Split(KestrelUrlSeparator);
if (url?[2] != null)
{
Console.WriteLine($"{nameof(BuildHost)} with {config}");
var hostBuilder = CreateHostBuilder(args, config);
return hostBuilder.Build();
Program.blazorPort = url[2];
}

private static IHostBuilder CreateHostBuilder(string[] args, IConfiguration config)
{
var url = config[KestrelEndpointsHttpUrl]?.Split(KestrelUrlSeparator);
if (url?[2] != null)
{
Program.blazorPort = url[2];
}

return Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder
.UseStartup<Startup>()
.UseUrls(DefaultUrl);
});
}
return Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder
.UseStartup<Startup>()
.UseUrls(DefaultUrl);
});
}

private static IConfigurationRoot LoadConfiguration()
{
Console.WriteLine($"Loading Configuration in path: {Directory.GetCurrentDirectory()}");
private static IConfigurationRoot LoadConfiguration()
{
Console.WriteLine($"Loading Configuration in path: {Directory.GetCurrentDirectory()}");

var config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile(AppSettingsFileName)
.AddEnvironmentVariables()
.Build();
return config;
}
var config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile(AppSettingsFileName)
.AddEnvironmentVariables()
.Build();
return config;
}
}
39 changes: 39 additions & 0 deletions src/AasxServerBlazorTests/AasxServerBlazorTests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AutoFixture" Version="4.18.1"/>
<PackageReference Include="AutoFixture.AutoMoq" Version="4.18.1"/>
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="6.12.0"/>
<PackageReference Include="JetBrains.Annotations" Version="2024.2.0-eap1"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0"/>
<PackageReference Include="Moq" Version="4.20.70"/>
<PackageReference Include="xunit" Version="2.8.1"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<Using Include="Xunit"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AasxServerBlazor\AasxServerBlazor.csproj" />
</ItemGroup>

</Project>
32 changes: 32 additions & 0 deletions src/AasxServerBlazorTests/Configuration/DependencyRegistryTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Microsoft.Extensions.DependencyInjection;
using AasxServerBlazor.Configuration;
using AasxServerBlazor.Data;
using IO.Swagger.Registry.Lib.V3.Interfaces;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;

public class DependencyRegistryTests
{
[Fact]
public void Register_ShouldRegisterAllServices()
{
// Arrange
var services = new ServiceCollection();
services.AddLogging(); // Add logging services

// Act
DependencyRegistry.Register(services);
var serviceProvider = services.BuildServiceProvider();

// Assert
// Verify Singleton Registrations
serviceProvider.GetService<AASService>().Should().NotBeNull();
serviceProvider.GetService<CredentialService>().Should().NotBeNull();
serviceProvider.GetService<IHttpContextAccessor>().Should().NotBeNull();
serviceProvider.GetService<IRegistryInitializerService>().Should().NotBeNull();
serviceProvider.GetService<IAuthorizationHandler>().Should().NotBeNull();

// Verify Scoped Registrations
serviceProvider.GetService<BlazorSessionService>().Should().NotBeNull();
}
}
5 changes: 5 additions & 0 deletions src/AasxServerBlazorTests/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
global using Xunit;
global using FluentAssertions;
global using Moq;
global using AutoFixture;
global using AutoFixture.AutoMoq;
1 change: 1 addition & 0 deletions src/AasxServerDB/AasxServerDB.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/AasxServerStandardBib/AasxServerStandardBib.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<!--<TargetFramework>netstandard2.0</TargetFramework>-->
<TargetFramework>net8.0</TargetFramework>
<SatelliteResourceLanguages>en-US;de-DE</SatelliteResourceLanguages>
<UserSecretsId>ef550880-6a5f-4e0c-b634-8284f1dc5445</UserSecretsId>
<Version>0.3.0.1-aasV3-alpha-latest</Version>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
</PropertyGroup>

<PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions src/DataTransferObjects/DataTransferObjects.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.3.0.1-aasV3-alpha-latest</Version>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
</PropertyGroup>

<PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions src/es6numberserializer/es6numberserializer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<TargetFramework>netstandard2.1</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>0.3.0.1-aasV3-alpha-latest</Version>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
</PropertyGroup>

</Project>

0 comments on commit 579bcca

Please sign in to comment.