コード例 #1
0
        public async Task Should_not_add_error_if_value_is_within_range(int?min, int?max)
        {
            var sut = new RangeValidator <int>(min, max);

            await sut.ValidateAsync(1500, errors);

            Assert.Equal(0, errors.Count);
        }
コード例 #2
0
        public async Task Should_not_add_error_if_value_is_null()
        {
            var sut = new RangeValidator <int>(100, 200);

            await sut.ValidateAsync(null, errors);

            Assert.Equal(0, errors.Count);
        }
コード例 #3
0
        public async Task Should_add_error_if_value_is_greater_than_max()
        {
            var sut = new RangeValidator <int>(null, 1000);

            await sut.ValidateAsync(1500, errors);

            errors.ShouldBeEquivalentTo(
                new[] { "<FIELD> must be less than '1000'." });
        }
コード例 #4
0
        public async Task Should_add_error_if_value_is_smaller_than_min()
        {
            var sut = new RangeValidator <int>(2000, null);

            await sut.ValidateAsync(1500, errors);

            errors.ShouldBeEquivalentTo(
                new[] { "<FIELD> must be greater than '2000'." });
        }