Esempio n. 1
0
        public void Should_add_error_if_inline_editing_is_not_allowed_for_editor(StringFieldEditor editor)
        {
            var sut = new StringFieldProperties {
                InlineEditable = true, Editor = editor, AllowedValues = ReadOnlyCollection.Create("Value")
            };

            var errors = FieldPropertiesValidator.Validate(sut).ToList();

            errors.Should().BeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Inline editing is only allowed for dropdowns, slugs and input fields.", "InlineEditable", "Editor")
            });
        }
Esempio n. 2
0
        public void Should_add_error_if_content_type_is_not_valid()
        {
            var sut = new StringFieldProperties {
                ContentType = (StringContentType)123
            };

            var errors = FieldPropertiesValidator.Validate(sut).ToList();

            errors.Should().BeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Content type is not a valid value.", "ContentType")
            });
        }
Esempio n. 3
0
        public void Should_add_error_if_pattern_is_not_valid_regex()
        {
            var sut = new StringFieldProperties {
                Pattern = "[0-9{1}"
            };

            var errors = FieldPropertiesValidator.Validate(sut).ToList();

            errors.Should().BeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Pattern is not a valid value.", "Pattern")
            });
        }
Esempio n. 4
0
        public void Should_add_error_if_only_aspect_height_is_defined()
        {
            var sut = new AssetsFieldProperties {
                AspectHeight = 10
            };

            var errors = FieldPropertiesValidator.Validate(sut).ToList();

            errors.ShouldBeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Aspect width and height must be defined.", "AspectWidth", "AspectHeight")
            });
        }
Esempio n. 5
0
        public void Should_add_error_if_default_value_is_greater_than_min()
        {
            var sut = new DateTimeFieldProperties {
                MaxValue = FutureDays(10), DefaultValue = FutureDays(15)
            };

            var errors = FieldPropertiesValidator.Validate(sut).ToList();

            errors.ShouldBeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Default value must be less than max value.", "DefaultValue")
            });
        }
Esempio n. 6
0
        public void Should_add_error_if_min_value_greater_than_max_value()
        {
            var sut = new DateTimeFieldProperties {
                MinValue = FutureDays(10), MaxValue = FutureDays(5)
            };

            var errors = FieldPropertiesValidator.Validate(sut).ToList();

            errors.Should().BeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Max value must be greater than min value.", "MinValue", "MaxValue")
            });
        }
Esempio n. 7
0
        public void Should_add_error_if_calculated_default_value_default_value_is_defined()
        {
            var sut = new DateTimeFieldProperties {
                CalculatedDefaultValue = DateTimeCalculatedDefaultValue.Now, DefaultValue = FutureDays(10)
            };

            var errors = FieldPropertiesValidator.Validate(sut).ToList();

            errors.Should().BeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Calculated default value and default value cannot be used together.", "CalculatedDefaultValue", "DefaultValue")
            });
        }
        public void Should_add_error_if_allowed_values_and_min_value_is_specified()
        {
            var sut = new StringFieldProperties {
                MaxLength = 10, AllowedValues = ImmutableList.Create("4")
            };

            var errors = FieldPropertiesValidator.Validate(sut).ToList();

            errors.ShouldBeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Either allowed values or min and max length can be defined.", "AllowedValues", "MinLength", "MaxLength")
            });
        }
Esempio n. 9
0
        public void Should_add_error_if_default_value_is_greater_than_min()
        {
            var sut = new NumberFieldProperties {
                MaxValue = 0, DefaultValue = 5
            };

            var errors = FieldPropertiesValidator.Validate(sut).ToList();

            errors.Should().BeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Default value must be less or equal to max value.", "DefaultValue")
            });
        }
Esempio n. 10
0
        public void Should_add_error_if_default_value_is_less_than_min()
        {
            var sut = new NumberFieldProperties {
                MinValue = 10, DefaultValue = 5
            };

            var errors = FieldPropertiesValidator.Validate(sut).ToList();

            errors.ShouldBeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Default value must be greater than min value.", "DefaultValue")
            });
        }
Esempio n. 11
0
        public void Should_add_error_if_inline_editing_is_not_allowed_for_editor(NumberFieldEditor editor)
        {
            var sut = new NumberFieldProperties {
                InlineEditable = true, Editor = editor, AllowedValues = ReadOnlyCollection.Create(1.0)
            };

            var errors = FieldPropertiesValidator.Validate(sut).ToList();

            errors.Should().BeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Inline editing is not allowed for Radio editor.", "InlineEditable", "Editor")
            });
        }
Esempio n. 12
0
        public void Should_add_error_if_min_size_greater_than_max_size()
        {
            var sut = new AssetsFieldProperties {
                MinSize = 10, MaxSize = 5
            };

            var errors = FieldPropertiesValidator.Validate(sut).ToList();

            errors.ShouldBeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Max size must be greater than min size.", "MinSize", "MaxSize")
            });
        }
Esempio n. 13
0
        public void Should_add_error_if_min_height_greater_than_max_height()
        {
            var sut = new AssetsFieldProperties {
                MinHeight = 10, MaxHeight = 5
            };

            var errors = FieldPropertiesValidator.Validate(sut).ToList();

            errors.ShouldBeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Max height must be greater than min height.", "MinHeight", "MaxHeight")
            });
        }
Esempio n. 14
0
        public void Should_add_error_if_min_width_greater_than_max_width()
        {
            var sut = new AssetsFieldProperties {
                MinWidth = 10, MaxWidth = 5
            };

            var errors = FieldPropertiesValidator.Validate(sut).ToList();

            errors.ShouldBeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Max width must be greater than min width.", "MinWidth", "MaxWidth")
            });
        }
Esempio n. 15
0
        public void Should_add_error_if_min_length_greater_than_max()
        {
            var sut = new StringFieldProperties {
                MinLength = 10, MaxLength = 5
            };

            var errors = FieldPropertiesValidator.Validate(sut).ToList();

            errors.Should().BeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Max length must be greater or equal to min length.", "MinLength", "MaxLength")
            });
        }
Esempio n. 16
0
        public void Should_add_error_if_min_greater_than_max()
        {
            var sut = new NumberFieldProperties {
                MinValue = 10, MaxValue = 5
            };

            var errors = FieldPropertiesValidator.Validate(sut).ToList();

            errors.Should().BeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Max value must be greater than min value.", "MinValue", "MaxValue")
            });
        }
Esempio n. 17
0
        public void Should_add_error_if_min_words_greater_than_max()
        {
            var sut = new StringFieldProperties {
                MinWords = 10, MaxWords = 5
            };

            var errors = FieldPropertiesValidator.Validate(sut).ToList();

            errors.Should().BeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Max words must be greater or equal to min words.", "MinWords", "MaxWords")
            });
        }
Esempio n. 18
0
        public void Should_add_error_if_allowed_values_and_min_value_is_specified()
        {
            var sut = new NumberFieldProperties {
                MinValue = 10, AllowedValues = ReadOnlyCollection.Create(4d)
            };

            var errors = FieldPropertiesValidator.Validate(sut).ToList();

            errors.Should().BeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Either allowed values or min and max value can be defined.", "AllowedValues", "MinValue", "MaxValue")
            });
        }
Esempio n. 19
0
        public void Should_add_error_if_calculated_default_value_is_not_valid()
        {
            var sut = new DateTimeFieldProperties {
                CalculatedDefaultValue = (DateTimeCalculatedDefaultValue)123
            };

            var errors = FieldPropertiesValidator.Validate(sut).ToList();

            errors.Should().BeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Calculated default value is not a valid value.", "CalculatedDefaultValue")
            });
        }
Esempio n. 20
0
        public void Should_add_error_if_resolving_references_with_more_than_one_max_items()
        {
            var sut = new ReferencesFieldProperties {
                ResolveReference = true, MaxItems = 2
            };

            var errors = FieldPropertiesValidator.Validate(sut).ToList();

            errors.Should().BeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Can only resolve references when MaxItems is 1.", "ResolveReference", "MaxItems")
            });
        }
        public void Should_add_error_if_editor_is_not_valid()
        {
            var sut = new BooleanFieldProperties {
                Editor = (BooleanFieldEditor)123
            };

            var errors = FieldPropertiesValidator.Validate(sut).ToList();

            errors.Should().BeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Editor is not a valid value.", "Editor")
            });
        }
Esempio n. 22
0
        public void Should_add_error_if_radio_button_has_no_allowed_values()
        {
            var sut = new StringFieldProperties {
                Editor = StringFieldEditor.Radio
            };

            var errors = FieldPropertiesValidator.Validate(sut).ToList();

            errors.Should().BeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Radio buttons or dropdown list need allowed values.", "AllowedValues")
            });
        }
Esempio n. 23
0
        public void Should_add_error_if_min_items_greater_than_max_items()
        {
            var sut = new AssetsFieldProperties {
                MinItems = 10, MaxItems = 5
            };

            var errors = FieldPropertiesValidator.Validate(sut).ToList();

            errors.ShouldBeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Max items must be greater than min items.", "MinItems", "MaxItems")
            });
        }
Esempio n. 24
0
        public void Should_add_error_if_inline_editing_is_not_allowed_for_editor(NumberFieldEditor editor)
        {
            var sut = new NumberFieldProperties {
                InlineEditable = true, Editor = editor, AllowedValues = ImmutableList.Create(1.0)
            };

            var errors = FieldPropertiesValidator.Validate(sut).ToList();

            errors.ShouldBeEquivalentTo(
                new List <ValidationError>
            {
                new ValidationError("Inline editing is only allowed for dropdowns and input fields.", "InlineEditable", "Editor")
            });
        }