public void AfterTodayAttributeTest_ShouldFail() { AfterTodayTest afterToday = new AfterTodayTest(); afterToday.MustBeAfterToday = new DateTime(1993, 10, 5); ValidationContext validationContext = new ValidationContext(afterToday) { MemberName = "MustBeAfterToday" }; Assert.IsFalse(Validator.TryValidateProperty(afterToday.MustBeAfterToday, validationContext, null)); }
public void AfterTodayAttributeTest_ShouldPass() { AfterTodayTest afterToday = new AfterTodayTest(); afterToday.MustBeAfterToday = new DateTime(2022, 10, 5); ValidationContext validationContext = new ValidationContext(afterToday) { MemberName = "MustBeAfterToday" }; var results = new List<ValidationResult>(); Assert.IsTrue(Validator.TryValidateProperty(afterToday.MustBeAfterToday, validationContext, results)); }