private ExpectationResult VerifyDoesNotHaveInstance(IPolicyContainer policyContainer, DoesNotHaveInstanceExpectation expectation)
 {
     if (expectation == null) return null;
     if (policyContainer != null && policyContainer.HasPolicy(expectation.Instance))
     {
         const string messageFormat = "An unexpected instance of the policy type \"{2}\" was found for controller \"{0}\", action \"{1}\".";
         var expectedPolicyType = expectation.Instance.GetType().Name;
         var message = string.Format(messageFormat, policyContainer.ControllerName, policyContainer.ActionName, expectedPolicyType);
         return _expectationViolationHandler.Handle(message);
     }
     return ExpectationResult.CreateSuccessResult();
 }
 private ExpectationResult VerifyDoesNotHaveInstance(IPolicyContainer policyContainer, DoesNotHaveInstanceExpectation expectation)
 {
     if (expectation == null)
     {
         return(null);
     }
     if (policyContainer != null && policyContainer.HasPolicy(expectation.Instance))
     {
         const string messageFormat      = "An unexpected instance of the policy type \"{2}\" was found for controller \"{0}\", action \"{1}\".";
         var          expectedPolicyType = expectation.Instance.GetType().Name;
         var          message            = string.Format(messageFormat, policyContainer.ControllerName, policyContainer.ActionName, expectedPolicyType);
         return(_expectationViolationHandler.Handle(message));
     }
     return(ExpectationResult.CreateSuccessResult());
 }
        private ExpectationResult VerifyHasInstance(IPolicyContainer policyContainer, HasInstanceExpectation expectation, string controllerName, string actionName)
        {
            if (expectation == null)
            {
                return(null);
            }
            if (policyContainer == null)
            {
                const string messageFormat = "Expected a configuration for controller \"{0}\", action \"{1}\". Policycontainer could not be found!";
                var          message       = string.Format(messageFormat, controllerName, actionName);
                return(_expectationViolationHandler.Handle(message));
            }

            if (policyContainer.HasPolicy(expectation.Instance) == false)
            {
                const string messageFormat      = "The expected instance of the policy \"{2}\" was not found! Controller \"{0}\", action \"{1}\".";
                var          expectedPolicyType = expectation.Instance.GetType().Name;
                var          message            = string.Format(messageFormat, policyContainer.ControllerName, policyContainer.ActionName, expectedPolicyType);
                return(_expectationViolationHandler.Handle(message));
            }
            return(ExpectationResult.CreateSuccessResult());
        }
        private ExpectationResult VerifyHasInstance(IPolicyContainer policyContainer, HasInstanceExpectation expectation, string controllerName, string actionName)
        {
            if (expectation == null) return null;
            if (policyContainer == null)
            {
                const string messageFormat = "Expected a configuration for controller \"{0}\", action \"{1}\". Policycontainer could not be found!";
                var message = string.Format(messageFormat, controllerName, actionName);
                return _expectationViolationHandler.Handle(message);
            }

            if (policyContainer.HasPolicy(expectation.Instance) == false)
            {
                const string messageFormat = "The expected instance of the policy \"{2}\" was not found! Controller \"{0}\", action \"{1}\".";
                var expectedPolicyType = expectation.Instance.GetType().Name;
                var message = string.Format(messageFormat, policyContainer.ControllerName, policyContainer.ActionName, expectedPolicyType);
                return _expectationViolationHandler.Handle(message);
            }
            return ExpectationResult.CreateSuccessResult();
        }