public async Task ValidateAsync_IsValidShouldBeFalse_When_AsyncValidationDelegateReturnsFalse() { var v = new ValidatableObject <string>(); v.Validations.Add(new ActionAsyncValidationRule <string>(arg => Task.FromResult(false), "You have entered an invalid email")); Assert.True(v.IsValid); v.Value = "*****@*****.**"; await v.ValidateAsync(); Assert.False(v.IsValid); Assert.True(v.Errors.Contains("You have entered an invalid email")); }
public async Task ValidateAsync_NotSupported() { var validatable = new ValidatableObject(false); await Assert.ThrowsAsync <NotSupportedException>(() => validatable.ValidateAsync <ValidatableObjectValidator2>(throwOnNotValidable: true)).ConfigureAwait(false); }
public async Task ValidateAsync_Exception() { var validatable = new ValidatableObject(false); await Assert.ThrowsAsync <ValidationException>(() => validatable.ValidateAsync <ValidatableObjectValidator>(throwOnValidationError: true)).ConfigureAwait(false); }