예제 #1
0
        public void Should_not_add_error_if_sut_is_valid()
        {
            var sut = new DateTimeFieldProperties
            {
                MinValue     = FutureDays(10),
                MaxValue     = FutureDays(20),
                DefaultValue = FutureDays(15)
            };

            sut.Validate(errors);

            Assert.Empty(errors);
        }
예제 #2
0
        public void Should_add_error_if_editor_is_not_valid()
        {
            var sut = new DateTimeFieldProperties {
                Editor = (DateTimeFieldEditor)123
            };

            sut.Validate(errors);

            errors.ShouldBeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Editor is not a valid value", "Editor")
            });
        }
예제 #3
0
        public void Should_add_error_if_min_greater_than_max()
        {
            var sut = new DateTimeFieldProperties {
                MinValue = FutureDays(10), MaxValue = FutureDays(5)
            };

            sut.Validate(errors);

            errors.ShouldBeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Max value must be greater than min value", "MinValue", "MaxValue")
            });
        }
예제 #4
0
        public void Should_add_error_if_default_value_is_greater_than_min()
        {
            var sut = new DateTimeFieldProperties {
                MaxValue = FutureDays(10), DefaultValue = FutureDays(15)
            };

            sut.Validate(errors);

            errors.ShouldBeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Default value must be less than max value", "DefaultValue")
            });
        }
예제 #5
0
        public void Should_add_error_if_calculated_default_value_default_value_is_defined()
        {
            var sut = new DateTimeFieldProperties {
                CalculatedDefaultValue = DateTimeCalculatedDefaultValue.Now, DefaultValue = FutureDays(10)
            };

            sut.Validate(errors);

            errors.ShouldBeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Calculated default value and default value cannot be used together", "CalculatedDefaultValue", "DefaultValue")
            });
        }
예제 #6
0
        public void Should_add_error_if_calculated_default_value_is_not_valid()
        {
            var sut = new DateTimeFieldProperties {
                CalculatedDefaultValue = (DateTimeCalculatedDefaultValue)123
            };

            sut.Validate(errors);

            errors.ShouldBeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Calculated default value is not valid", "CalculatedDefaultValue")
            });
        }