public void ErrorMessage_MaxFormat_AreEqual() { string column = "測試欄位"; DateTime maxDateTime = new DateTime(1912, 3, 3); DateTimeValidator validator = DateTimeValidator.CreateMaxDateTime(column, "1912/03/04", maxDateTime); validator.Validate(); Assert.AreEqual( string.Format(validator.MaxValueErrorMessageFormat, column, maxDateTime), validator.ErrorMessage ); }
public void ErrorMessage_MaxCustomFormat_AreEqual() { string column = "測試欄位"; DateTime maxDateTime = new DateTime(1912, 3, 3); DateTimeValidator validator = DateTimeValidator.CreateMaxDateTime(column, "1912/03/04", maxDateTime, customRangeMessageFormat: "{0}_{1}DateTime"); validator.Validate(); Assert.AreEqual( string.Format(validator.CustomRangeMessageFormat, column, maxDateTime), validator.ErrorMessage ); }
public void Validate_Max_AreEqual(string value, bool isValid) { DateTimeValidator validator = DateTimeValidator.CreateMaxDateTime("", value, new DateTime(1912, 3, 2)); Assert.AreEqual(validator.Validate(), isValid); }
public Func <string, string, DateTimeValidator> MaxDateTime(DateTime max, string maxDateTimeErrorMessageFormat = null) => (column, value) => DateTimeValidator.CreateMaxDateTime(column, value, max, null, maxDateTimeErrorMessageFormat);