public void CanCreateValidationCallHandlerThroughFactory() { ValidationCallHandlerData validationCallHandler = new ValidationCallHandlerData("validationHandler"); IUnityContainer container = new UnityContainer().AddNewExtension <Interception>(); RuleDrivenPolicy policy = CreatePolicySetContainingCallHandler(validationCallHandler, container); ICallHandler runtimeHandler = (policy.GetHandlersFor(new MethodImplementationInfo(null, (MethodInfo)MethodBase.GetCurrentMethod()), container)).ElementAt(0); Assert.IsNotNull(runtimeHandler); }
public void CanCreateCustomAttributeMatchingRuleNodeFromData() { ValidationCallHandlerData handlerData = new ValidationCallHandlerData(); handlerData.Name = "validationHandler"; handlerData.SpecificationSource = SpecificationSource.Both; handlerData.RuleSet = "ruleSet"; ValidationCallHandlerNode handlerNode = new ValidationCallHandlerNode(handlerData); Assert.AreEqual(handlerData.Name, handlerNode.Name); Assert.AreEqual(handlerData.SpecificationSource, handlerNode.SpecificationSource); Assert.AreEqual(handlerData.RuleSet, handlerNode.RuleSet); }
public void CanDeserializeValidationCallHandlerData() { ValidationCallHandlerData data = new ValidationCallHandlerData("Logging Handler"); data.RuleSet = "MyRuleSet"; data.SpecificationSource = SpecificationSource.Configuration; ValidationCallHandlerData deserialized = (ValidationCallHandlerData)SerializeAndDeserializeHandler(data); Assert.AreEqual(data.RuleSet, deserialized.RuleSet); Assert.AreEqual(data.SpecificationSource, deserialized.SpecificationSource); Assert.AreEqual(typeof(ValidationCallHandler), deserialized.Type); }
public void CanCreateValidationCallHandlerThroughFactory() { ValidationCallHandlerData validationCallHandler = new ValidationCallHandlerData("validationHandler"); IUnityContainer container = new UnityContainer().AddNewExtension <Interception>(); new UnityContainerConfigurator(container) .RegisterAll(new DictionaryConfigurationSource(), new ValidationTypeRegistrationProvider()); InjectionFriendlyRuleDrivenPolicy policy = CreatePolicySetContainingCallHandler(validationCallHandler, container); ICallHandler runtimeHandler = (policy.GetHandlersFor(new MethodImplementationInfo(null, (MethodInfo)MethodBase.GetCurrentMethod()), container)).ElementAt(0); Assert.IsNotNull(runtimeHandler); }
static InjectionFriendlyRuleDrivenPolicy CreatePolicySetContainingCallHandler( ValidationCallHandlerData validationCallHandler, IUnityContainer container) { PolicyInjectionSettings settings = new PolicyInjectionSettings(); PolicyData policyData = new PolicyData("policy"); policyData.MatchingRules.Add(new CustomMatchingRuleData("match everything", typeof(AlwaysMatchingRule))); policyData.Handlers.Add(validationCallHandler); settings.Policies.Add(policyData); DictionaryConfigurationSource dictionaryConfigurationSource = new DictionaryConfigurationSource(); dictionaryConfigurationSource.Add(PolicyInjectionSettings.SectionName, settings); settings.ConfigureContainer(container, dictionaryConfigurationSource); return(container.Resolve <InjectionFriendlyRuleDrivenPolicy>("policy")); }