public void IsValidReturnsFalseWhenGivenNullObject()
        {
            var rule = new DateCannotExceedOtherDateRule <string>(s => null, string.Empty, s => null, string.Empty);

            bool isValid = rule.IsValid(null);

            Assert.IsFalse(isValid, "Null object returned true.");
        }
        public void GetErrorMessageReturnsMessageWhenGivenNonNullObjectWithNullDate()
        {
            var rule = new DateCannotExceedOtherDateRule <FakeObjectToValidate>(f => null, string.Empty, f => null, string.Empty);

            string message = rule.GetErrorMessage(new FakeObjectToValidate());

            Assert.IsNotNull(message);
            Assert.IsNotEmpty(message);
        }
        public void IsValidReturnsFalsIfFirstDateExceedsTheSecondDate()
        {
            var date = new DateTime(2001, 1, 1);
            var rule = new DateCannotExceedOtherDateRule <FakeObjectToValidate>(f => date.AddDays(1), string.Empty, f => date, string.Empty);

            bool isValid = rule.IsValid(new FakeObjectToValidate());

            Assert.IsFalse(isValid, "IsValid returned true even though the first date was later than the second.");
        }
        public void IsValidReturnsTrueIfFirstDateMatchesSecondDate()
        {
            var date = new DateTime(2001, 1, 1);
            var rule = new DateCannotExceedOtherDateRule <FakeObjectToValidate>(f => date, string.Empty, f => date, string.Empty);

            bool isValid = rule.IsValid(new FakeObjectToValidate());

            Assert.IsTrue(isValid, "IsValid returned false even though the first date matches the second.");
        }
        public void IsValidReturnsTrueIfSecondDateIsNull()
        {
            var rule = new DateCannotExceedOtherDateRule <FakeObjectToValidate>(f => f.NullableDateTime, string.Empty, f => null, string.Empty);

            bool isValid = rule.IsValid(new FakeObjectToValidate {
                NullableDateTime = new DateTime(2001, 1, 1)
            });

            Assert.IsTrue(isValid, "IsValid returned false even though the second date was null.");
        }