public void Should_return_action_result_from_violation_handler_that_match_name()
        {
            // Arrange
            var nonMatchingNameViolationHandler = new NonMatchingNameViolationHandler();
            var matchingNameViolationHandler = new MatchingNameViolationHandler();
            var violationHandlers = new List<IPolicyViolationHandler>
            {
                nonMatchingNameViolationHandler,
                matchingNameViolationHandler
            };
            var failureResult = PolicyResult.CreateFailureResult(new IgnorePolicy(), "Access denied");
            var policy = new DelegatePolicy("MatchingName", c => failureResult);
            var delegatePolicyResult = new DelegatePolicyResult(failureResult, policy.Name, policy.ViolationHandler);
            var exception = new PolicyViolationException(delegatePolicyResult);
            var handler = new DelegatePolicyViolationHandler(violationHandlers);

            // Act
            var result = handler.Handle(exception);

            // Assert
            Assert.That(result, Is.EqualTo(matchingNameViolationHandler.ActionResult));
        }
        public void Should_return_action_result_from_violation_handler_that_match_name()
        {
            // Arrange
            var nonMatchingNameViolationHandler = new NonMatchingNameViolationHandler();
            var matchingNameViolationHandler    = new MatchingNameViolationHandler();
            var violationHandlers = new List <IPolicyViolationHandler>
            {
                nonMatchingNameViolationHandler,
                matchingNameViolationHandler
            };
            var failureResult        = PolicyResult.CreateFailureResult(new IgnorePolicy(), "Access denied");
            var policy               = new DelegatePolicy("MatchingName", c => failureResult);
            var delegatePolicyResult = new DelegatePolicyResult(failureResult, policy.Name, policy.ViolationHandler);
            var exception            = new PolicyViolationException(delegatePolicyResult);
            var handler              = new DelegatePolicyViolationHandler(violationHandlers);

            // Act
            var result = handler.Handle(exception);

            // Assert
            Assert.That(result, Is.EqualTo(matchingNameViolationHandler.ActionResult));
        }