57 lines
1.9 KiB
C#
57 lines
1.9 KiB
C#
using System.Reflection;
|
|
using Mccn.ArchitectureTests.Abstractions;
|
|
using Mccn.Modules.Users.Application;
|
|
using Mccn.Modules.Users.Domain.Users;
|
|
using Mccn.Modules.Users.Infrastructure;
|
|
using NetArchTest.Rules;
|
|
|
|
namespace Mccn.ArchitectureTests.Layers;
|
|
|
|
public class ModuleTests : BaseTest
|
|
{
|
|
[Fact]
|
|
public void UsersModule_ShouldNotHaveDependencyOn_HelloModule()
|
|
{
|
|
List<Assembly> usersAssemblies =
|
|
[
|
|
typeof(User).Assembly,
|
|
AssemblyReference.Assembly,
|
|
Modules.Users.Presentation.AssemblyReference.Assembly,
|
|
typeof(DependencyInjection).Assembly
|
|
];
|
|
|
|
// Check each Hello implementation namespace individually.
|
|
// Hello.IntegrationEvents would be an allowed reference (public contract), but Hello has none.
|
|
foreach (string ns in HelloImplementationNamespaces)
|
|
{
|
|
Types.InAssemblies(usersAssemblies)
|
|
.Should()
|
|
.NotHaveDependencyOn(ns)
|
|
.GetResult()
|
|
.ShouldBeSuccessful();
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void HelloModule_ShouldNotHaveDependencyOn_UsersModule()
|
|
{
|
|
List<Assembly> helloAssemblies =
|
|
[
|
|
Modules.Hello.Application.AssemblyReference.Assembly,
|
|
Modules.Hello.Presentation.AssemblyReference.Assembly,
|
|
typeof(Modules.Hello.Infrastructure.DependencyInjection).Assembly
|
|
];
|
|
|
|
// Check each Users implementation namespace individually.
|
|
// Users.IntegrationEvents is explicitly excluded as it is a public contract
|
|
// that other modules are permitted to reference.
|
|
foreach (string ns in UsersImplementationNamespaces)
|
|
{
|
|
Types.InAssemblies(helloAssemblies)
|
|
.Should()
|
|
.NotHaveDependencyOn(ns)
|
|
.GetResult()
|
|
.ShouldBeSuccessful();
|
|
}
|
|
}
|
|
} |