Skip to content

Why is my test failing? #157

@matthiasguentert

Description

@matthiasguentert

Consider the following assemblies, where each of them are having a marker interface:

  • Api (IApiMarker)
  • Infrastructure (IInfrastructureMarker)
  • Application (IApplicationMarker)
  • Domain (IDomainMarker)
  • SharedKernel (ISharedKernelMarker)

... and further the following references:

  1. Api has a reference to Infrastructure
  2. Infrastructure has a reference to Application
  3. Application has a reference to Domain and SharedKernel
  4. Domain has a reference to SharedKernel
  5. SharedKernel doesn't have any references

Now, I'd like to make sure, that these references stay in place and that dependencies only flow inwards (clean architecture).

I therefore created a test, let's call it ArchTest which references Api.

Now I'd like to ensure, that domain holds a reference to sharedkernel... (not sure if this test makes much sense...) But, why is the following test failing even so Domain has a reference to SharedKernel?

[Fact]
public void Domain_should_have_reference_to_shared_kernel()
{
    var domain = typeof(IDomainMarker).Assembly;
    var sharedKernel = typeof(ISharedKernelMarker).Assembly;

    var result = Types.InAssembly(domain)
        .Should()
        .HaveDependencyOn(sharedKernel.GetName().Name)
        .GetResult();
    
    result.IsSuccessful.ShouldBeTrue();
}

P.S: Using NetArchTest.Rules v1.3.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions