コード例 #1
0
        public async Task Should_not_add_error_if_number_is_valid()
        {
            var sut = new NumberField(1, "my-number", new NumberFieldProperties());

            await sut.ValidateAsync(CreateValue(null), errors);

            Assert.Empty(errors);
        }
コード例 #2
0
        public async Task Should_not_add_error_if_number_is_valid()
        {
            var sut = new NumberField(1, "my-number", Partitioning.Invariant);

            await sut.ValidateAsync(CreateValue(null), false, errors);

            Assert.Empty(errors);
        }
コード例 #3
0
        private NumberField AddField()
        {
            var field = new NumberField(1, "my-field", new NumberFieldProperties());

            sut = sut.AddOrUpdateField(field);

            return(field);
        }
コード例 #4
0
ファイル: SchemaTests.cs プロジェクト: alexsandrocruz/squidex
        private NumberField AddField()
        {
            var field = new NumberField(1, "my-field", Partitioning.Invariant);

            sut = sut.AddOrUpdateField(field);

            return(field);
        }
コード例 #5
0
        public async Task Should_add_errors_if_value_is_not_valid()
        {
            var sut = new NumberField(1, "my-number", Partitioning.Invariant);

            await sut.ValidateAsync(CreateValue("Invalid"), false, errors);

            errors.ShouldBeEquivalentTo(
                new[] { "<FIELD> is not a valid value" });
        }
コード例 #6
0
        public async Task Should_add_errors_if_value_is_not_valid()
        {
            var sut = new NumberField(1, "my-number", new NumberFieldProperties());

            await sut.ValidateAsync(CreateValue("Invalid"), errors);

            errors.ShouldBeEquivalentTo(
                new[] { "<FIELD> is not a valid value" });
        }
コード例 #7
0
        public async Task Should_add_errors_if_number_is_not_allowed()
        {
            var sut = new NumberField(1, "my-number", Partitioning.Invariant, new NumberFieldProperties {
                AllowedValues = ImmutableList.Create(10d)
            });

            await sut.ValidateAsync(CreateValue(20), false, errors);

            errors.ShouldBeEquivalentTo(
                new[] { "<FIELD> is not an allowed value" });
        }
コード例 #8
0
        public async Task Should_add_errors_if_number_is_greater_than_max()
        {
            var sut = new NumberField(1, "my-number", Partitioning.Invariant, new NumberFieldProperties {
                MaxValue = 10
            });

            await sut.ValidateAsync(CreateValue(20), false, errors);

            errors.ShouldBeEquivalentTo(
                new[] { "<FIELD> must be less than '10'" });
        }
コード例 #9
0
        public async Task Should_add_errors_if_number_is_required()
        {
            var sut = new NumberField(1, "my-number", Partitioning.Invariant, new NumberFieldProperties {
                IsRequired = true
            });

            await sut.ValidateAsync(CreateValue(null), false, errors);

            errors.ShouldBeEquivalentTo(
                new[] { "<FIELD> is required" });
        }
コード例 #10
0
        public async Task Should_add_errors_if_number_is_less_than_min()
        {
            var sut = new NumberField(1, "my-number", new NumberFieldProperties {
                MinValue = 10
            });

            await sut.ValidateAsync(CreateValue(5), errors);

            errors.ShouldBeEquivalentTo(
                new[] { "<FIELD> must be greater than '10'" });
        }
コード例 #11
0
        public void Should_clone_object()
        {
            var sut = new NumberField(1, "my-number", Partitioning.Invariant);

            Assert.NotEqual(sut, sut.Enable());
        }
コード例 #12
0
        public void Should_instantiate_field()
        {
            var sut = new NumberField(1, "my-number", Partitioning.Invariant);

            Assert.Equal("my-number", sut.Name);
        }
コード例 #13
0
        public void Should_clone_object()
        {
            var sut = new NumberField(1, "my-number", new NumberFieldProperties());

            Assert.NotEqual(sut, sut.Enable());
        }
コード例 #14
0
        public void Should_instantiate_field()
        {
            var sut = new NumberField(1, "my-number", new NumberFieldProperties());

            Assert.Equal("my-number", sut.Name);
        }