示例#1
0
        public void CanCheckForFurtureDateValidationOnFutureDate()
        {
            DateTime dateToCheck = DateTime.Today.AddDays(1);
            var      attr        = new FutureDateAttribute();

            var result = attr.IsValid(dateToCheck);

            Assert.AreEqual(false, result);
        }
示例#2
0
        public void IsValidTest()
        {
            FutureDateAttribute target = new FutureDateAttribute(); // TODO: Initialize to an appropriate value
            object value    = null;                                 // TODO: Initialize to an appropriate value
            bool   expected = false;                                // TODO: Initialize to an appropriate value
            bool   actual;

            actual = target.IsValid(value);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
示例#3
0
        public void WhenValueToday_ValidationSucceeds()
        {
            var validator = new FutureDateAttribute();

            var instance = new object();

            var datetime = (DateTime?)DateTime.UtcNow;

            var context             = new ValidationContext(instance, null, null);
            ValidationResult result = validator.GetValidationResult(datetime, context);

            Assert.Same(ValidationResult.Success, result);
        }
示例#4
0
        public void WhenValueInPast_ValidationFails()
        {
            var validator = new FutureDateAttribute();

            var instance = new object();

            var datetime = (DateTime?)DateTime.UtcNow.AddDays(-2);

            var context = new ValidationContext(instance, null, null);

            context.MemberName = "MyDate";
            ValidationResult result = validator.GetValidationResult(datetime, context);

            Assert.NotSame(ValidationResult.Success, result);
            Assert.NotNull(result.ErrorMessage);
        }