-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using ArchUnitNET.Domain.Extensions; | ||
using ArchUnitNET.Fluent; | ||
using ArchUnitNET.Loader; | ||
using ArchUnitNET.xUnit; | ||
using MadWorld.Backend.API.Anonymous; | ||
using MadWorld.Backend.API.Authorized; | ||
using MadWorld.Backend.API.Shared; | ||
using MadWorld.Backend.Application; | ||
using MadWorld.Backend.Domain; | ||
using MadWorld.Backend.Infrastructure; | ||
|
||
//add a using directive to ArchUnitNET.Fluent.ArchRuleDefinition to easily define ArchRules | ||
using static ArchUnitNET.Fluent.ArchRuleDefinition; | ||
|
||
namespace MadWorld.Architecture.Tests; | ||
|
||
public class DependencyTests | ||
{ | ||
private static readonly ArchUnitNET.Domain.Architecture Architecture = new ArchLoader().LoadAssemblies( | ||
typeof(DomainMarker).Assembly, | ||
typeof(AnonymousMarker).Assembly, | ||
typeof(AuthorizedMarker).Assembly, | ||
typeof(SharedMarker).Assembly, | ||
typeof(ApplicationMarker).Assembly, | ||
typeof(InfrastructureMarker).Assembly) | ||
.Build(); | ||
|
||
private static readonly string DomainNamespace = typeof(DomainMarker).Namespace!; | ||
private static readonly string AnonymousNamespace = typeof(AnonymousMarker).Namespace!; | ||
private static readonly string AuthorizedNamespace = typeof(AuthorizedMarker).Namespace!; | ||
private static readonly string SharedNamespace = typeof(SharedMarker).Namespace!; | ||
private static readonly string ApplicationNamespace = typeof(ApplicationMarker).Namespace!; | ||
private static readonly string InfrastructureNamespace = typeof(InfrastructureMarker).Namespace!; | ||
|
||
[Fact] | ||
public void ApplicationDependsNotOnInfrastructure() | ||
{ | ||
var rule = Types().That().ResideInNamespace($"{ApplicationNamespace}.*", true) | ||
.Should().NotDependOnAny($"{InfrastructureNamespace}.*", true); | ||
|
||
rule.Check(Architecture); | ||
} | ||
|
||
[Fact] | ||
public void DomainDependsNotOnBackendProject() | ||
{ | ||
var backendProjects = new List<string>() | ||
{ | ||
$"{AnonymousNamespace}.*", | ||
$"{AuthorizedNamespace}.*", | ||
$"{SharedNamespace}.*", | ||
$"{ApplicationNamespace}.*", | ||
$"{InfrastructureNamespace}.*", | ||
}; | ||
|
||
var rule = Types().That().ResideInNamespace($"{DomainNamespace}.*", true) | ||
.Should().NotDependOnAny(backendProjects, true); | ||
|
||
rule.Check(Architecture); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
MadWorld/MadWorld.Architecture.Tests/MadWorld.Architecture.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" /> | ||
<PackageReference Include="TngTech.ArchUnitNET" /> | ||
<PackageReference Include="TngTech.ArchUnitNET.xUnit" /> | ||
<PackageReference Include="xunit" /> | ||
<PackageReference Include="xunit.runner.visualstudio"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\MadWorld.Backend.API.Anonymous\MadWorld.Backend.API.Anonymous.csproj" /> | ||
<ProjectReference Include="..\MadWorld.Backend.API.Authorized\MadWorld.Backend.API.Authorized.csproj" /> | ||
<ProjectReference Include="..\MadWorld.Backend.Application\MadWorld.Backend.Application.csproj" /> | ||
<ProjectReference Include="..\MadWorld.Backend.Infrastructure\MadWorld.Backend.Infrastructure.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
global using Xunit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace MadWorld.Backend.API.Anonymous; | ||
|
||
public interface AnonymousMarker | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace MadWorld.Backend.API.Authorized; | ||
|
||
public interface AuthorizedMarker | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace MadWorld.Backend.API.Shared; | ||
|
||
public interface SharedMarker | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace MadWorld.Backend.Application; | ||
|
||
public interface ApplicationMarker | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace MadWorld.Backend.Domain; | ||
|
||
public interface DomainMarker | ||
{ | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
MadWorld/MadWorld.Backend.Infrastructure/InfrastructureMarker.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace MadWorld.Backend.Infrastructure; | ||
|
||
public interface InfrastructureMarker | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters