Closed Parus1 closed 1 year ago
Hi, the below example seems to produce correct results, i.e. fails on the InterfaceImplementationB class:
InterfaceImplementationB
public interface IInterfaceA { } public interface IInterfaceB { } internal class InterfaceImplementationA : IInterfaceA { } public class InterfaceImplementationB : IInterfaceB { } [Fact] public void InterfaceImplementationsShouldBeInternal() { var policy = Policy.Define("Interface Implementations", "Interface implementations should be internal") .For(NetArchTest.Rules.Types.FromPath(AppDomain.CurrentDomain.BaseDirectory)) .Add(types => types.That() .ImplementInterface(typeof(IInterfaceB)) .Should() .NotBePublic()) .Add(types => types.That() .ImplementInterface(typeof(IInterfaceA)) .Should() .NotBePublic()); var results = policy.Evaluate(); Assert.False(results.HasViolations); }
But, when I change the order of policy rules to the below, the test starts passing:
[Fact] public void InterfaceImplementationsShouldBeInternal() { var policy = Policy.Define("Interface Implementations", "Interface implementations should be internal") .For(NetArchTest.Rules.Types.FromPath(AppDomain.CurrentDomain.BaseDirectory)) .Add(types => types.That() .ImplementInterface(typeof(IInterfaceA)) .Should() .NotBePublic()) .Add(types => types.That() .ImplementInterface(typeof(IInterfaceB)) .Should() .NotBePublic()); var results = policy.Evaluate(); Assert.False(results.HasViolations); }
Am I missing something in the implementation of policies, or is there a potential issue here?
Hi, the below example seems to produce correct results, i.e. fails on the
InterfaceImplementationB
class:But, when I change the order of policy rules to the below, the test starts passing:
Am I missing something in the implementation of policies, or is there a potential issue here?