File tree Expand file tree Collapse file tree 6 files changed +1905
-0
lines changed Expand file tree Collapse file tree 6 files changed +1905
-0
lines changed Original file line number Diff line number Diff line change 55 <Project Path =" src/Services/Services.csproj" />
66 </Folder >
77 <Folder Name =" /tests/" >
8+ <Project Path =" tests/ArchitectureTests/ArchitectureTests.csproj" />
89 <Project Path =" tests/IntegrationTests/IntegrationTests.csproj" />
910 <Project Path =" tests/UnitTests/UnitTests.csproj" />
1011 </Folder >
Original file line number Diff line number Diff line change 1+ using System . Runtime . CompilerServices ;
2+
3+ [ assembly: InternalsVisibleTo ( "ArchitectureTests" ) ]
Original file line number Diff line number Diff line change 1+ <Project Sdk =" Microsoft.NET.Sdk" >
2+ <PropertyGroup >
3+ <IsPackable >false</IsPackable >
4+ <UseMicrosoftTestingPlatformRunner >true</UseMicrosoftTestingPlatformRunner >
5+ <TestingPlatformDotnetTestSupport >true</TestingPlatformDotnetTestSupport >
6+ <TestingPlatformShowTestsFailure >true</TestingPlatformShowTestsFailure >
7+ </PropertyGroup >
8+ <ItemGroup >
9+ <ProjectReference Include =" ..\..\src\Api\Api.csproj" />
10+ <ProjectReference Include =" ..\..\src\Common\Common.csproj" />
11+ </ItemGroup >
12+ <ItemGroup >
13+ <PackageReference Include =" Microsoft.NET.Test.Sdk" />
14+ <PackageReference Include =" Microsoft.Testing.Extensions.CodeCoverage" />
15+ <PackageReference Include =" xunit.v3" />
16+ <PackageReference Include =" xunit.runner.visualstudio" >
17+ <IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
18+ <PrivateAssets >all</PrivateAssets >
19+ </PackageReference >
20+ </ItemGroup >
21+ <ItemGroup >
22+ <Content Include =" ..\xunit.runner.json" CopyToOutputDirectory =" PreserveNewest" />
23+ </ItemGroup >
24+ </Project >
Original file line number Diff line number Diff line change 1+ using Xunit ;
2+
3+ namespace ArchitectureTests ;
4+
5+ public class AssemblyReferenceTests
6+ {
7+
8+ [ Fact ]
9+ public void Common_HasNoUnexpectedAssemblyReferences ( )
10+ {
11+ var commonAssembly = typeof ( Common . EnvVarKeys ) . Assembly ;
12+
13+ var referencedAssemblies = commonAssembly
14+ . GetReferencedAssemblies ( )
15+ . Select ( a => a . Name )
16+ . ToList ( ) ;
17+
18+ var allowed = new [ ]
19+ {
20+ "System" ,
21+ "mscorlib" ,
22+ "netstandard" ,
23+ "System.Core" ,
24+ "Microsoft.CSharp" ,
25+ commonAssembly . GetName ( ) . Name !
26+ } ;
27+
28+ var forbidden = referencedAssemblies
29+ . Where ( x => ! allowed . Any ( y => x ? . StartsWith ( y , StringComparison . InvariantCulture ) ?? false ) )
30+ . ToList ( ) ;
31+
32+ Assert . Empty ( forbidden ) ;
33+ }
34+ }
Original file line number Diff line number Diff line change 1+ using Api . Setup ;
2+ using Microsoft . AspNetCore . Builder ;
3+ using Microsoft . Extensions . DependencyInjection ;
4+ using Services ;
5+ using Xunit ;
6+
7+ namespace ArchitectureTests ;
8+
9+ public class ServiceRegistrationTests
10+ {
11+ [ Fact ]
12+ public void ShouldHave_Scoped_MarketClient ( )
13+ {
14+ var builder = WebApplication . CreateBuilder ( ) ;
15+ builder . Services . ConfigureServices ( ) ;
16+
17+ var marketClient = builder . Services . SingleOrDefault ( x => x . ServiceType == typeof ( IMarketClient ) ) ;
18+
19+ Assert . NotNull ( marketClient ) ;
20+ Assert . Equal ( ServiceLifetime . Scoped , marketClient . Lifetime ) ;
21+ }
22+
23+ [ Fact ]
24+ public void ShouldHave_Scoped_MarketService ( )
25+ {
26+ var builder = WebApplication . CreateBuilder ( ) ;
27+ builder . Services . ConfigureServices ( ) ;
28+
29+ var marketService = builder . Services . SingleOrDefault ( x => x . ServiceType == typeof ( IMarketService ) ) ;
30+
31+ Assert . NotNull ( marketService ) ;
32+ Assert . Equal ( ServiceLifetime . Scoped , marketService . Lifetime ) ;
33+ }
34+ }
You can’t perform that action at this time.
0 commit comments