Example #1
0
 public void Given()
 {
     var instrumentationProvider = new MockValidationInstrumentationProvider();
     validationFactory = new CompositeValidatorFactory(
         instrumentationProvider,
         new ValidatorFactory[]
             {
                 new AttributeValidatorFactory(instrumentationProvider),
                 new ConfigurationValidatorFactory(ConfigurationSourceFactory.Create(), instrumentationProvider)
             });
 }
Example #2
0
        public void Given()
        {
            DictionaryConfigurationSource configurationSource = new DictionaryConfigurationSource();
            ValidationSettings settings = new ValidationSettings();
            configurationSource.Add(ValidationSettings.SectionName, settings);
            ValidatedTypeReference typeReference = new ValidatedTypeReference(typeof(TestObjectWithFailingAttributesOnProperties));
            settings.Types.Add(typeReference);
            typeReference.DefaultRuleset = "RuleA";
            ValidationRulesetData ruleData = new ValidationRulesetData("RuleA");
            typeReference.Rulesets.Add(ruleData);
            ValidatedPropertyReference propertyReference1 = new ValidatedPropertyReference("FailingProperty1");
            ruleData.Properties.Add(propertyReference1);
            MockValidatorData validator11 = new MockValidatorData("validator1", true);
            propertyReference1.Validators.Add(validator11);
            validator11.MessageTemplate = "message-from-config1-RuleA";
            MockValidatorData validator12 = new MockValidatorData("validator2", true);
            propertyReference1.Validators.Add(validator12);
            validator12.MessageTemplate = "message-from-config2-RuleA";
            MockValidatorData validator13 = new MockValidatorData("validator3", false);
            propertyReference1.Validators.Add(validator13);
            validator13.MessageTemplate = "message-from-config3-RuleA";

            MockValidationInstrumentationProvider instrumentationProvider = new MockValidationInstrumentationProvider();

            validationFactory = new CompositeValidatorFactory(
                instrumentationProvider,
                new ValidatorFactory[]
                    {
                        new AttributeValidatorFactory(instrumentationProvider),
                        new ConfigurationValidatorFactory(configurationSource, instrumentationProvider)
                    });
        }