public void InstanceConfiguredWithNullPropertyNameThrows()
 {
     PropertyProxyValidatorImplementation implementation
         = new PropertyProxyValidatorImplementation("012345678901",
             typeof(ValidationSubject),
             null,
             "",
             ValidationSpecificationSource.Attributes,
             null,
             ValidationSummaryDisplayMode.List);
 }
Esempio n. 2
0
 public void InstanceConfiguredWithInvalidPropertyNameThrows()
 {
     PropertyProxyValidatorImplementation implementation
         = new PropertyProxyValidatorImplementation("012345678901",
                                                    typeof(ValidationSubject),
                                                    "Not a property name",
                                                    "",
                                                    ValidationSpecificationSource.Attributes,
                                                    null,
                                                    ValidationSummaryDisplayMode.List);
 }
		public void InstanceConfiguredForUnsuccessfulValidationReturnsValidMessageAndValidationState()
		{
			PropertyProxyValidatorImplementation implementation
				= new PropertyProxyValidatorImplementation("012345678901",
					typeof(ValidationSubject),
					"ValidationProperty",
					"",
					ValidationSpecificationSource.Attributes,
					null,
					ValidationSummaryDisplayMode.SingleParagraph);

			Assert.IsFalse(implementation.IsValid);
			Assert.AreNotEqual("", implementation.ErrorMessage);
		}
Esempio n. 4
0
        public void InstanceConfiguredForUnsuccessfulValidationReturnsValidMessageAndValidationState()
        {
            PropertyProxyValidatorImplementation implementation
                = new PropertyProxyValidatorImplementation("012345678901",
                                                           typeof(ValidationSubject),
                                                           "ValidationProperty",
                                                           "",
                                                           ValidationSpecificationSource.Attributes,
                                                           null,
                                                           ValidationSummaryDisplayMode.SingleParagraph);

            Assert.IsFalse(implementation.IsValid);
            Assert.AreNotEqual("", implementation.ErrorMessage);
        }
Esempio n. 5
0
        public void InstanceCreatedWithNonNullValueConverterWillReturnConversionErrorIfConverterThrows()
        {
            string sourceValueToValidate = "2006-01-10T00:00:00";

            PropertyProxyValidatorImplementation implementation
                = new PropertyProxyValidatorImplementation(sourceValueToValidate,
                                                           typeof(ValidationSubject),
                                                           "DateTimeValidationPropertyWithMockValidator",
                                                           "",
                                                           ValidationSpecificationSource.Attributes,
                                                           this.ConvertValueThrowing,
                                                           ValidationSummaryDisplayMode.SingleParagraph);

            Assert.IsTrue(this.converterInvoked);
            Assert.AreEqual(0, MockValidator <object> .CreatedValidators.Count);
            Assert.IsFalse(implementation.IsValid);
            Assert.IsTrue(implementation.ErrorMessage.Contains(Resources.ErrorConversionFailedMessage));
        }
Esempio n. 6
0
        public void InstanceCreatedWithNullValueConverterWillValidateTheOriginalValue()
        {
            string sourceValueToValidate = "2006-01-10T00:00:00";

            PropertyProxyValidatorImplementation implementation
                = new PropertyProxyValidatorImplementation(sourceValueToValidate,
                                                           typeof(ValidationSubject),
                                                           "StringValidationPropertyWithMockValidator",
                                                           "",
                                                           ValidationSpecificationSource.Attributes,
                                                           null,
                                                           ValidationSummaryDisplayMode.SingleParagraph);

            MockValidator <object> createdValidator = MockValidator <object> .CreatedValidators[0];

            Assert.IsFalse(this.converterInvoked);
            Assert.AreEqual(sourceValueToValidate, createdValidator.ValidatedTargets[0]);
        }
Esempio n. 7
0
        public void InstanceCreatedWithNonNullValueConverterWillInvokeConverterAndValidateTheConvertedValue()
        {
            string sourceValueToValidate = "2006-01-10T00:00:00";

            PropertyProxyValidatorImplementation implementation
                = new PropertyProxyValidatorImplementation(sourceValueToValidate,
                                                           typeof(ValidationSubject),
                                                           "DateTimeValidationPropertyWithMockValidator",
                                                           "",
                                                           ValidationSpecificationSource.Attributes,
                                                           this.ConvertValue,
                                                           ValidationSummaryDisplayMode.SingleParagraph);

            MockValidator <object> createdValidator = MockValidator <object> .CreatedValidators[0];

            Assert.IsTrue(this.converterInvoked);
            Assert.AreEqual(this.converterValue, createdValidator.ValidatedTargets[0]);
            Assert.AreSame(sourceValueToValidate, this.converterSourceValue);
            Assert.AreSame(typeof(DateTime), this.converterTargetType);
        }
		public void InstanceCreatedWithNonNullValueConverterWillReturnConversionErrorIfConverterThrows()
		{
			string sourceValueToValidate = "2006-01-10T00:00:00";

			PropertyProxyValidatorImplementation implementation
				= new PropertyProxyValidatorImplementation(sourceValueToValidate,
					typeof(ValidationSubject),
					"DateTimeValidationPropertyWithMockValidator",
					"",
					ValidationSpecificationSource.Attributes,
					this.ConvertValueThrowing,
					ValidationSummaryDisplayMode.SingleParagraph);

			Assert.IsTrue(this.converterInvoked);
			Assert.AreEqual(0, MockValidator<object>.CreatedValidators.Count);
			Assert.IsFalse(implementation.IsValid);
			Assert.IsTrue(implementation.ErrorMessage.Contains(Resources.ErrorConversionFailedMessage));
		}
		public void InstanceCreatedWithNonNullValueConverterWillInvokeConverterAndValidateTheConvertedValue()
		{
			string sourceValueToValidate = "2006-01-10T00:00:00";

			PropertyProxyValidatorImplementation implementation
				= new PropertyProxyValidatorImplementation(sourceValueToValidate,
					typeof(ValidationSubject),
					"DateTimeValidationPropertyWithMockValidator",
					"",
					ValidationSpecificationSource.Attributes,
					this.ConvertValue,
					ValidationSummaryDisplayMode.SingleParagraph);

			MockValidator<object> createdValidator = MockValidator<object>.CreatedValidators[0];
			Assert.IsTrue(this.converterInvoked);
			Assert.AreEqual(this.converterValue, createdValidator.ValidatedTargets[0]);
			Assert.AreSame(sourceValueToValidate, this.converterSourceValue);
			Assert.AreSame(typeof(DateTime), this.converterTargetType);
		}
		public void InstanceCreatedWithNullValueConverterWillValidateTheOriginalValue()
		{
			string sourceValueToValidate = "2006-01-10T00:00:00";

			PropertyProxyValidatorImplementation implementation
				= new PropertyProxyValidatorImplementation(sourceValueToValidate,
					typeof(ValidationSubject),
					"StringValidationPropertyWithMockValidator",
					"",
					ValidationSpecificationSource.Attributes,
					null,
					ValidationSummaryDisplayMode.SingleParagraph);

			MockValidator<object> createdValidator = MockValidator<object>.CreatedValidators[0];
			Assert.IsFalse(this.converterInvoked);
			Assert.AreEqual(sourceValueToValidate, createdValidator.ValidatedTargets[0]);
		}