Skip to content

A powerful library to simply define & test custom/well known architectures

License

Notifications You must be signed in to change notification settings

Hona/ArchitectureTests

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hona.ArchitectureTests

Usage

The most simple way to use the library is to use the predefined architecture suites.

[Fact]
public void CleanArchitecture()
{
    Ensure.CleanArchitecture(x =>
    {
        x.Presentation = new TypesPart([typeof(ConsolePresenter), typeof(Program), typeof(LogHelper)]);
        x.Application = new AggregatePart(
        [
            new NamespacePart(SampleAppAssembly, ".Jobs"),
            new NamespacePart(SampleAppAssembly, ".Services")
        ]);
        x.Domain = new NamespacePart(SampleAppAssembly, ".Models");
        x.Infrastructure = new AggregatePart(
        [
            new NamespacePart(SampleAppAssembly, ".Data"),
            new AssemblyPart(typeof(WebApiClient).Assembly)
        ]);
    }).Assert();
}

For custom architectures, you can define application parts, then setup the rules. For example a basic 'Clean Architecture' implementation without the suite, would look like this

private static readonly Assembly SampleAppAssembly = typeof(ISampleApp).Assembly;

private static readonly IApplicationPart Presentation =
    new TypesPart([typeof(ConsolePresenter), typeof(Program), typeof(LogHelper)]);

private static readonly IApplicationPart Application =
    new NamespacePart(SampleAppAssembly, ".Jobs");

private static readonly IApplicationPart Domain =
    new NamespacePart(SampleAppAssembly, ".Models");

private static readonly IApplicationPart Infrastructure =
    new NamespacePart(SampleAppAssembly, ".Data");

[Fact]
public void Presentation_DependsOn_Application()
{
    Ensure.That(Presentation)
        .DependsOn(Application)
        .Assert();
}

[Fact]
public void Application_DependsOn_Domain()
{
    Ensure.That(Application)
        .DependsOn(Domain)
        .Assert();
}

[Fact]
public void Infrastructure_DependsOn_Application()
{
    Ensure.That(Infrastructure)
        .DependsOn(Application)
        .Assert();
}

About

A powerful library to simply define & test custom/well known architectures

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages