public static void ShouldPass(this IValueCheck check, object parsedValue, string value)
        {
            var vr = check.Validate(value, parsedValue, CultureInfo.CurrentCulture);

            vr.IsValid.Should().BeTrue();
            vr.Exception.Should().BeNull();
        }
Exemple #2
0
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            var stringValue = Convert.ToString(value);
            var vr          = _check.Validate(stringValue, stringValue, cultureInfo ?? CultureInfo.CurrentCulture);

            var error = vr.Exception;

            return(new ValidationResult(vr.IsValid, error?.Message ?? string.Empty));
        }
        public static void ShouldFailWith <TError>(this IValueCheck check, string value, object parsedValue,
                                                   Predicate <TError> matchError = null)
            where TError : Exception
        {
            var vr = check.Validate(value, parsedValue, CultureInfo.CurrentCulture);

            vr.IsValid.Should().BeFalse();
            var error = (TError)vr.Exception;

            error.Should().NotBeNull();
            matchError?.Invoke(error).Should().BeTrue();
        }