コード例 #1
0
        private NumberField AddField()
        {
            var field = new NumberField(1, "my-field", Partitioning.Invariant);

            sut = sut.AddOrUpdateField(field);

            return(field);
        }
コード例 #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), errors);

            Assert.Empty(errors);
        }
コード例 #3
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"), errors);

            errors.ShouldBeEquivalentTo(
                new[] { "<FIELD> is not a valid value." });
        }
コード例 #4
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), errors);

            errors.ShouldBeEquivalentTo(
                new[] { "<FIELD> is not an allowed value." });
        }
コード例 #5
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), errors);

            errors.ShouldBeEquivalentTo(
                new[] { "<FIELD> must be less than '10'." });
        }
コード例 #6
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), errors);

            errors.ShouldBeEquivalentTo(
                new[] { "<FIELD> is required." });
        }
コード例 #7
0
        public void Should_clone_object()
        {
            var sut = new NumberField(1, "my-number", Partitioning.Invariant);

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

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