コード例 #1
0
        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
                );
        }
コード例 #2
0
        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
                );
        }
コード例 #3
0
        public void Validate_Max_AreEqual(string value, bool isValid)
        {
            DateTimeValidator validator = DateTimeValidator.CreateMaxDateTime("", value, new DateTime(1912, 3, 2));

            Assert.AreEqual(validator.Validate(), isValid);
        }
コード例 #4
0
 public Func <string, string, DateTimeValidator> MaxDateTime(DateTime max, string maxDateTimeErrorMessageFormat = null)
 => (column, value) => DateTimeValidator.CreateMaxDateTime(column, value, max, null, maxDateTimeErrorMessageFormat);