Ejemplo n.º 1
0
		public void return_correct_validator_based_on_property_name(string propertyName, PropertyValidator validator)
		{
			// Arrange
			var expectedResult = validator.GetType();

			// Act
			var result = ValidatorFactory.getValidator(propertyName).GetType();
			
			// Assert
			Assert.AreEqual(expectedResult, result);
		}
Ejemplo n.º 2
0
        protected override string GetDefaultMessageTemplate(string errorCode)
        {
            MethodInfo sourceMethod =
                _sourceValidator.GetType().GetMethod(
                    nameof(GetDefaultMessageTemplate),
                    BindingFlags.Instance | BindingFlags.NonPublic,
                    Type.DefaultBinder,
                    new[] { typeof(string) },
                    null);

            if (sourceMethod == null)
            {
                throw new NotImplementedException();
            }

            var baseMsg = (string)sourceMethod.Invoke(_sourceValidator, new object[] { errorCode });

            var sb = new StringBuilder(baseMsg);

            sb.Append(" This property is optional and can be null.");

            return(sb.ToString());
        }