public async Task Should_not_add_error_if_value_is_null() { var sut = new RangeValidator <int>(100, 200); await sut.ValidateAsync(null, errors); Assert.Empty(errors); }
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.Empty(errors); }
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 or equals than '1000'." }); }
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 or equals than '2000'." }); }
public async Task Should_add_error_if_value_is_not_equal_to_min_and_max() { var sut = new RangeValidator <int>(2000, 2000); await sut.ValidateAsync(1500, errors); errors.Should().BeEquivalentTo( new[] { "Must be exactly '2000'." }); }