public async Task Should_not_add_error_if_value_is_empty() { var sut = new PatternValidator("[a-z]{3}:[0-9]{2}"); await sut.ValidateAsync(string.Empty, errors); Assert.Empty(errors); }
public async Task Should_add_timeout_error_when_regex_is_too_slow() { var sut = new PatternValidator(@"^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$"); await sut.ValidateAsync("https://archiverbx.blob.core.windows.net/static/C:/Users/USR/Documents/Projects/PROJ/static/images/full/1234567890.jpg", errors); errors.ShouldBeEquivalentTo( new[] { "Regex is too slow." }); }
public async Task Should_add_error_with_custom_message_if_value_is_not_valid() { var sut = new PatternValidator("[a-z]{3}:[0-9]{2}", "Custom Error Message."); await sut.ValidateAsync("foo", errors); errors.ShouldBeEquivalentTo( new[] { "Custom Error Message." }); }
public async Task Should_add_error_with_default_message_if_value_is_not_valid() { var sut = new PatternValidator("[a-z]{3}:[0-9]{2}"); await sut.ValidateAsync("foo", errors); errors.ShouldBeEquivalentTo( new[] { "<FIELD> is not valid." }); }