private ExpectationResult VerifyDoesNotHaveType(IPolicyContainer policyContainer, DoesNotHaveTypeExpectation expectation) { if (expectation == null) return null; if (policyContainer != null && policyContainer.HasPolicyOfType(expectation.Type)) { const string messageFormat = "An unexpected policy of type \"{2}\" was found for controller \"{0}\", action \"{1}\"."; var message = string.Format(messageFormat, policyContainer.ControllerName, policyContainer.ActionName, expectation.Type); return _expectationViolationHandler.Handle(message); } return ExpectationResult.CreateSuccessResult(); }
private ExpectationResult VerifyHasType(IPolicyContainer policyContainer, HasTypeExpectation 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.HasPolicyOfType(expectation.Type) == false) { const string messageFormat = "Expected policy of type \"{2}\" for controller \"{0}\", action \"{1}\"!"; var message = string.Format(messageFormat, policyContainer.ControllerName, policyContainer.ActionName, expectation.Type); return _expectationViolationHandler.Handle(message); } return ExpectationResult.CreateSuccessResult(); }