Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange behavior when applying Or/And condition #38

Closed
Vertygo opened this issue Feb 21, 2020 · 1 comment
Closed

Strange behavior when applying Or/And condition #38

Vertygo opened this issue Feb 21, 2020 · 1 comment

Comments

@Vertygo
Copy link

Vertygo commented Feb 21, 2020

Hi @BenMorris , I have been playing with the NetArchTest and while doing so I have run into two cases that might look like a bug.

In first example I have used And condition where GetResult() IsSuccess is returning false with the empty FailingTypes list.

namespace Test
{
    public class Dependency
    {
    }

    public class ClassA
    {
        public Dependency Dep { get; set; }
    }
}

namespace Test.B
{
    public class ClassB
    {
        public Dependency Dep { get; set; }
    }

}

...

    var result = Types.InNamespace("Test")
        .That()
        .HaveDependencyOn(typeof(Dependency).FullName)
        .Should()
        .HaveName(typeof(ClassA).Name)
        .And()
        .ResideInNamespace(typeof(ClassB).Namespace)
        .GetResult();

In second example I'm using Or condition where GetResult() IsSuccess is returning false but all three classes show up in a FailingTypes list.

namespace Test
{
    public class Dependency
    {
    }

    public class ClassA
    {
        public Dependency Dep { get; set; }
    }
}

namespace Test.B
{
    public class ClassB
    {
        public Dependency Dep { get; set; }
    }

}

namespace Test.D
{
    public class ClassD
    {
        public Dependency Dep { get; set; }
    }
}

...

    var result = Types.InNamespace("Test")
        .That()
        .HaveDependencyOn(typeof(Dependency).FullName)
        .Should()
        .HaveName(typeof(ClassA).Name)
        .Or()
        .ResideInNamespace(typeof(ClassB).Namespace)
        .GetResult();

@BenMorris
Copy link
Owner

Thanks for this - a good spot and really clear example. This should be fixed in the following pull request: #39

With this fix, the first example will return both types in the failing list, while the second example will only return Test.D.ClassD.

I'll get this released over the next couple of days.

BenMorris added a commit that referenced this issue Feb 22, 2020
OR based statements will now return the correct type list (Issue #38)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants