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"));
        }
예제 #2
0
        public async Task ValidateAsync_NotSupported()
        {
            var validatable = new ValidatableObject(false);

            await Assert.ThrowsAsync <NotSupportedException>(() => validatable.ValidateAsync <ValidatableObjectValidator2>(throwOnNotValidable: true)).ConfigureAwait(false);
        }
예제 #3
0
        public async Task ValidateAsync_Exception()
        {
            var validatable = new ValidatableObject(false);

            await Assert.ThrowsAsync <ValidationException>(() => validatable.ValidateAsync <ValidatableObjectValidator>(throwOnValidationError: true)).ConfigureAwait(false);
        }