public void ReturnsValueOfSinglePolicy(bool expected, IInterceptionPolicy policy, IInvocation invocation)
        {
            policy.ShouldIntercept(invocation).Returns(expected);

            var sut = new AndInterceptionPolicy(policy);

            var result = sut.ShouldIntercept(invocation);

            result.Should().Be(expected);
        }
Пример #2
0
        public void ReturnsValueOfSinglePolicy(bool expected, IInterceptionPolicy policy, IInvocation invocation)
        {
            policy.ShouldIntercept(invocation).Returns(expected);

            var sut = new AndInterceptionPolicy(policy);

            var result = sut.ShouldIntercept(invocation);

            result.Should().Be(expected);
        }
Пример #3
0
 public void Intercept(IInvocation invocation)
 {
     if (_policy.ShouldIntercept(invocation))
     {
         _interceptor.Intercept(invocation);
     }
     else
     {
         _elseInterceptor.Intercept(invocation);
     }
 }
        public void FalsePolicyDecisionDoesntCallInterceptor(IInterceptionPolicy policy,
            IInterceptor interceptor,
            IInterceptor elseInterceptor,
            IInvocation invocation)
        {
            var sut = new FilteringInterceptor(policy, interceptor, elseInterceptor);
            policy.ShouldIntercept(invocation).Returns(true);

            sut.Intercept(invocation);

            elseInterceptor.DidNotReceive().Intercept(invocation);
        }
        public void FalsePolicyDecisionCallsElseInterceptor(IInterceptionPolicy policy,
            IInterceptor interceptor,
            IInterceptor elseInterceptor,
            IInvocation invocation)
        {
            var sut = new FilteringInterceptor(policy, interceptor, elseInterceptor);
            policy.ShouldIntercept(invocation).Returns(false);

            sut.Intercept(invocation);

            elseInterceptor.Received().Intercept(invocation);
        }
Пример #6
0
        public void TruePolicyDecisionDoesntCallElseInterceptor(IInterceptionPolicy policy,
                                                                IInterceptor interceptor,
                                                                IInterceptor elseInterceptor,
                                                                IInvocation invocation)
        {
            var sut = new FilteringInterceptor(policy, interceptor, elseInterceptor);

            policy.ShouldIntercept(invocation).Returns(false);

            sut.Intercept(invocation);

            interceptor.DidNotReceive().Intercept(invocation);
        }
Пример #7
0
        public void FalsePolicyDecisionCallsElseInterceptor(IInterceptionPolicy policy,
                                                            IInterceptor interceptor,
                                                            IInterceptor elseInterceptor,
                                                            IInvocation invocation)
        {
            var sut = new FilteringInterceptor(policy, interceptor, elseInterceptor);

            policy.ShouldIntercept(invocation).Returns(false);

            sut.Intercept(invocation);

            elseInterceptor.Received().Intercept(invocation);
        }
        public void ReturnsAllOfMultiplePolicies(bool a, bool b, bool expected,
            IInterceptionPolicy policyA,
            IInterceptionPolicy policyB,
            IInvocation invocation)
        {
            policyA.ShouldIntercept(invocation).Returns(a);
            policyB.ShouldIntercept(invocation).Returns(b);

            var sut = new AndInterceptionPolicy(policyA, policyB);

            var result = sut.ShouldIntercept(invocation);

            result.Should().Be(expected);
        }
Пример #9
0
        public void ReturnsAllOfMultiplePolicies(bool a, bool b, bool expected,
                                                 IInterceptionPolicy policyA,
                                                 IInterceptionPolicy policyB,
                                                 IInvocation invocation)
        {
            policyA.ShouldIntercept(invocation).Returns(a);
            policyB.ShouldIntercept(invocation).Returns(b);

            var sut = new AndInterceptionPolicy(policyA, policyB);

            var result = sut.ShouldIntercept(invocation);

            result.Should().Be(expected);
        }
 public bool ShouldIntercept(IInvocation invocation)
 {
     return(!_wrapped.ShouldIntercept(invocation));
 }