Exemplo n.º 1
0
        public async Task Should_not_add_error_if_value_is_empty()
        {
            var sut = new StringLengthValidator(100, 200);

            await sut.ValidateAsync(string.Empty, errors);

            Assert.Empty(errors);
        }
Exemplo n.º 2
0
        public async Task Should_not_add_error_if_value_is_within_range(int?min, int?max)
        {
            var sut = new StringLengthValidator(min, max);

            await sut.ValidateAsync(CreateString(1500), errors);

            Assert.Empty(errors);
        }
Exemplo n.º 3
0
        public async Task Should_not_add_error_if_value_is_null()
        {
            var sut = new StringLengthValidator();

            await sut.ValidateAsync(null, errors);

            Assert.Empty(errors);
        }
Exemplo n.º 4
0
        public async Task Should_add_error_if_value_is_greater_than_max()
        {
            var sut = new StringLengthValidator(null, 1000);

            await sut.ValidateAsync(CreateString(1500), errors);

            errors.ShouldBeEquivalentTo(
                new[] { "<FIELD> must have less than '1000' characters." });
        }
Exemplo n.º 5
0
        public async Task Should_add_error_if_value_is_smaller_than_min()
        {
            var sut = new StringLengthValidator(2000, null);

            await sut.ValidateAsync(CreateString(1500), errors);

            errors.ShouldBeEquivalentTo(
                new[] { "<FIELD> must have more than '2000' characters." });
        }
Exemplo n.º 6
0
        public async Task Should_add_error_if_collection_count_is_not_in_range()
        {
            var sut = new StringLengthValidator(2000, 5000);

            await sut.ValidateAsync(CreateString(1), errors);

            errors.Should().BeEquivalentTo(
                new[] { "Must have between 2000 and 5000 character(s)." });
        }
Exemplo n.º 7
0
        public async Task Should_add_error_if_value_is_greater_than_max()
        {
            var sut = new StringLengthValidator(null, 1000);

            await sut.ValidateAsync(CreateString(1500), errors);

            errors.Should().BeEquivalentTo(
                new[] { "Must not have more than 1000 character(s)." });
        }
Exemplo n.º 8
0
        public async Task Should_add_error_if_value_is_smaller_than_min()
        {
            var sut = new StringLengthValidator(2000, null);

            await sut.ValidateAsync(CreateString(1500), errors);

            errors.Should().BeEquivalentTo(
                new[] { "Must have at least 2000 character(s)." });
        }
Exemplo n.º 9
0
        public async Task Should_add_error_if_value_has_not_exact_number_of_characters()
        {
            var sut = new StringLengthValidator(2000, 2000);

            await sut.ValidateAsync(CreateString(4), errors);

            errors.Should().BeEquivalentTo(
                new[] { "Must have exactly 2000 character(s)." });
        }