public void CanDeserializeSerializedInstanceWithValuesSet()
        {
            MockValidationSettings rwSettings = new MockValidationSettings();
            TypeConversionValidatorData rwValidatorData = new TypeConversionValidatorData("validator1");
            rwSettings.Validators.Add(rwValidatorData);
            rwValidatorData.Negated = true;
            rwValidatorData.TargetType = typeof(double);

            IDictionary<string, ConfigurationSection> sections = new Dictionary<string, ConfigurationSection>();
            sections[ValidationSettings.SectionName] = rwSettings;

            using (ConfigurationFileHelper configurationFileHelper = new ConfigurationFileHelper(sections))
            {
                IConfigurationSource configurationSource = configurationFileHelper.ConfigurationSource;

                MockValidationSettings roSettings = configurationSource.GetSection(ValidationSettings.SectionName) as MockValidationSettings;

                Assert.IsNotNull(roSettings);
                Assert.AreEqual(1, roSettings.Validators.Count);
                Assert.AreEqual("validator1", roSettings.Validators.Get(0).Name);
                Assert.AreSame(typeof(TypeConversionValidator), roSettings.Validators.Get(0).Type);
                Assert.AreEqual(true, ((TypeConversionValidatorData)roSettings.Validators.Get(0)).Negated);
                Assert.AreEqual(typeof(double), ((TypeConversionValidatorData)roSettings.Validators.Get(0)).TargetType);
            }
        }
        public void CanCreateValidatorFromConfigurationObject()
        {
            TypeConversionValidatorData rwValidatorData = new TypeConversionValidatorData("validator1");
            rwValidatorData.Negated = true;
            rwValidatorData.TargetType = typeof(double);

            Validator validator = ((IValidatorDescriptor)rwValidatorData).CreateValidator(null, null, null, null);

            Assert.IsNotNull(validator);
            Assert.AreSame(typeof(TypeConversionValidator), validator.GetType());
            Assert.AreEqual(Resources.TypeConversionNegatedDefaultMessageTemplate, validator.MessageTemplate);
            Assert.AreEqual(true, ((TypeConversionValidator)validator).Negated);
            Assert.AreEqual(typeof(double), ((TypeConversionValidator)validator).TargetType);
        }