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); }
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()); }