Skip to main content

ValidationTestExtension

Assembly: ServiceStack.dll
View Source
Declaration
public static class ValidationTestExtension

Methods

ShouldHaveValidationErrorFor<T, TValue>(IValidator<T>, Expression<Func<T, TValue>>, TValue, String)

View Source
Declaration
public static IEnumerable<ValidationFailure> ShouldHaveValidationErrorFor<T, TValue>(this IValidator<T> validator, Expression<Func<T, TValue>> expression, TValue value, string ruleSet = null)
where T : class, new()
Returns

System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>

Parameters
TypeName
ServiceStack.FluentValidation.IValidator<T>validator
System.Linq.Expressions.Expression<System.Func<<T>,<TValue>>>expression
<TValue>value
System.StringruleSet
Type Parameters
  • T
  • TValue

ShouldHaveValidationErrorFor<T, TValue>(IValidator<T>, Expression<Func<T, TValue>>, T, String)

View Source
Declaration
public static IEnumerable<ValidationFailure> ShouldHaveValidationErrorFor<T, TValue>(this IValidator<T> validator, Expression<Func<T, TValue>> expression, T objectToTest, string ruleSet = null)
where T : class
Returns

System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>

Parameters
TypeName
ServiceStack.FluentValidation.IValidator<T>validator
System.Linq.Expressions.Expression<System.Func<<T>,<TValue>>>expression
<T>objectToTest
System.StringruleSet
Type Parameters
  • T
  • TValue

ShouldNotHaveValidationErrorFor<T, TValue>(IValidator<T>, Expression<Func<T, TValue>>, TValue, String)

View Source
Declaration
public static void ShouldNotHaveValidationErrorFor<T, TValue>(this IValidator<T> validator, Expression<Func<T, TValue>> expression, TValue value, string ruleSet = null)
where T : class, new()
Parameters
TypeName
ServiceStack.FluentValidation.IValidator<T>validator
System.Linq.Expressions.Expression<System.Func<<T>,<TValue>>>expression
<TValue>value
System.StringruleSet
Type Parameters
  • T
  • TValue

ShouldNotHaveValidationErrorFor<T, TValue>(IValidator<T>, Expression<Func<T, TValue>>, T, String)

View Source
Declaration
public static void ShouldNotHaveValidationErrorFor<T, TValue>(this IValidator<T> validator, Expression<Func<T, TValue>> expression, T objectToTest, string ruleSet = null)
where T : class
Parameters
TypeName
ServiceStack.FluentValidation.IValidator<T>validator
System.Linq.Expressions.Expression<System.Func<<T>,<TValue>>>expression
<T>objectToTest
System.StringruleSet
Type Parameters
  • T
  • TValue

ShouldHaveValidationErrorForAsync<T, TValue>(IValidator<T>, Expression<Func<T, TValue>>, TValue, CancellationToken, String)

View Source
Declaration
public static async Task<IEnumerable<ValidationFailure>> ShouldHaveValidationErrorForAsync<T, TValue>(this IValidator<T> validator, Expression<Func<T, TValue>> expression, TValue value, CancellationToken cancellationToken = default(CancellationToken), string ruleSet = null)
where T : class, new()
Returns

System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>>

Parameters
TypeName
ServiceStack.FluentValidation.IValidator<T>validator
System.Linq.Expressions.Expression<System.Func<<T>,<TValue>>>expression
<TValue>value
System.Threading.CancellationTokencancellationToken
System.StringruleSet
Type Parameters
  • T
  • TValue

ShouldHaveValidationErrorForAsync<T, TValue>(IValidator<T>, Expression<Func<T, TValue>>, T, CancellationToken, String)

View Source
Declaration
public static async Task<IEnumerable<ValidationFailure>> ShouldHaveValidationErrorForAsync<T, TValue>(this IValidator<T> validator, Expression<Func<T, TValue>> expression, T objectToTest, CancellationToken cancellationToken = default(CancellationToken), string ruleSet = null)
where T : class
Returns

System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>>

Parameters
TypeName
ServiceStack.FluentValidation.IValidator<T>validator
System.Linq.Expressions.Expression<System.Func<<T>,<TValue>>>expression
<T>objectToTest
System.Threading.CancellationTokencancellationToken
System.StringruleSet
Type Parameters
  • T
  • TValue

ShouldNotHaveValidationErrorForAsync<T, TValue>(IValidator<T>, Expression<Func<T, TValue>>, TValue, CancellationToken, String)

View Source
Declaration
public static async Task ShouldNotHaveValidationErrorForAsync<T, TValue>(this IValidator<T> validator, Expression<Func<T, TValue>> expression, TValue value, CancellationToken cancellationToken = default(CancellationToken), string ruleSet = null)
where T : class, new()
Returns

System.Threading.Tasks.Task

Parameters
TypeName
ServiceStack.FluentValidation.IValidator<T>validator
System.Linq.Expressions.Expression<System.Func<<T>,<TValue>>>expression
<TValue>value
System.Threading.CancellationTokencancellationToken
System.StringruleSet
Type Parameters
  • T
  • TValue

ShouldNotHaveValidationErrorForAsync<T, TValue>(IValidator<T>, Expression<Func<T, TValue>>, T, CancellationToken, String)

View Source
Declaration
public static async Task ShouldNotHaveValidationErrorForAsync<T, TValue>(this IValidator<T> validator, Expression<Func<T, TValue>> expression, T objectToTest, CancellationToken cancellationToken = default(CancellationToken), string ruleSet = null)
where T : class
Returns

System.Threading.Tasks.Task

Parameters
TypeName
ServiceStack.FluentValidation.IValidator<T>validator
System.Linq.Expressions.Expression<System.Func<<T>,<TValue>>>expression
<T>objectToTest
System.Threading.CancellationTokencancellationToken
System.StringruleSet
Type Parameters
  • T
  • TValue

ShouldHaveChildValidator<T, TProperty>(IValidator<T>, Expression<Func<T, TProperty>>, Type)

View Source
Declaration
public static void ShouldHaveChildValidator<T, TProperty>(this IValidator<T> validator, Expression<Func<T, TProperty>> expression, Type childValidatorType)
Parameters
TypeName
ServiceStack.FluentValidation.IValidator<T>validator
System.Linq.Expressions.Expression<System.Func<<T>,<TProperty>>>expression
System.TypechildValidatorType
Type Parameters
  • T
  • TProperty

TestValidate<T>(IValidator<T>, T, String)

View Source
Declaration
public static TestValidationResult<T> TestValidate<T>(this IValidator<T> validator, T objectToTest, string ruleSet = null)
where T : class
Returns

ServiceStack.FluentValidation.TestHelper.TestValidationResult<T>

Parameters
TypeName
ServiceStack.FluentValidation.IValidator<T>validator
<T>objectToTest
System.StringruleSet
Type Parameters
  • T

TestValidateAsync<T>(IValidator<T>, T, CancellationToken, String)

View Source
Declaration
public static async Task<TestValidationResult<T>> TestValidateAsync<T>(this IValidator<T> validator, T objectToTest, CancellationToken cancellationToken = default(CancellationToken), string ruleSet = null)
where T : class
Returns

System.Threading.Tasks.Task<ServiceStack.FluentValidation.TestHelper.TestValidationResult<<T>>>

Parameters
TypeName
ServiceStack.FluentValidation.IValidator<T>validator
<T>objectToTest
System.Threading.CancellationTokencancellationToken
System.StringruleSet
Type Parameters
  • T

TestValidate<T>(IValidator<T>, T, Action<ValidationStrategy<T>>)

View Source
Declaration
public static TestValidationResult<T> TestValidate<T>(this IValidator<T> validator, T objectToTest, Action<ValidationStrategy<T>> options)
where T : class
Returns

ServiceStack.FluentValidation.TestHelper.TestValidationResult<T>

Parameters
TypeName
ServiceStack.FluentValidation.IValidator<T>validator
<T>objectToTest
System.Action<ServiceStack.FluentValidation.Internal.ValidationStrategy<<T>>>options
Type Parameters
  • T

TestValidateAsync<T>(IValidator<T>, T, Action<ValidationStrategy<T>>, CancellationToken)

View Source
Declaration
public static async Task<TestValidationResult<T>> TestValidateAsync<T>(this IValidator<T> validator, T objectToTest, Action<ValidationStrategy<T>> options, CancellationToken cancellationToken = default(CancellationToken))
where T : class
Returns

System.Threading.Tasks.Task<ServiceStack.FluentValidation.TestHelper.TestValidationResult<<T>>>

Parameters
TypeName
ServiceStack.FluentValidation.IValidator<T>validator
<T>objectToTest
System.Action<ServiceStack.FluentValidation.Internal.ValidationStrategy<<T>>>options
System.Threading.CancellationTokencancellationToken
Type Parameters
  • T

ShouldHaveAnyValidationError<T>(TestValidationResult<T>)

View Source
Declaration
public static IEnumerable<ValidationFailure> ShouldHaveAnyValidationError<T>(this TestValidationResult<T> testValidationResult)
where T : class
Returns

System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>

Parameters
TypeName
ServiceStack.FluentValidation.TestHelper.TestValidationResult<T>testValidationResult
Type Parameters
  • T

ShouldNotHaveAnyValidationErrors<T>(TestValidationResult<T>)

View Source
Declaration
public static void ShouldNotHaveAnyValidationErrors<T>(this TestValidationResult<T> testValidationResult)
where T : class
Parameters
TypeName
ServiceStack.FluentValidation.TestHelper.TestValidationResult<T>testValidationResult
Type Parameters
  • T

When(IEnumerable<ValidationFailure>, Func<ValidationFailure, Boolean>, String)

View Source
Declaration
public static IEnumerable<ValidationFailure> When(this IEnumerable<ValidationFailure> failures, Func<ValidationFailure, bool> failurePredicate, string exceptionMessage = null)
Returns

System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>

Parameters
TypeName
System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>failures
System.Func<ServiceStack.FluentValidation.Results.ValidationFailure,System.Boolean>failurePredicate
System.StringexceptionMessage

WhenAll(IEnumerable<ValidationFailure>, Func<ValidationFailure, Boolean>, String)

View Source
Declaration
public static IEnumerable<ValidationFailure> WhenAll(this IEnumerable<ValidationFailure> failures, Func<ValidationFailure, bool> failurePredicate, string exceptionMessage = null)
Returns

System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>

Parameters
TypeName
System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>failures
System.Func<ServiceStack.FluentValidation.Results.ValidationFailure,System.Boolean>failurePredicate
System.StringexceptionMessage

WithSeverity(IEnumerable<ValidationFailure>, Severity)

View Source
Declaration
public static IEnumerable<ValidationFailure> WithSeverity(this IEnumerable<ValidationFailure> failures, Severity expectedSeverity)
Returns

System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>

Parameters
TypeName
System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>failures
ServiceStack.FluentValidation.SeverityexpectedSeverity

WithCustomState(IEnumerable<ValidationFailure>, Object)

View Source
Declaration
public static IEnumerable<ValidationFailure> WithCustomState(this IEnumerable<ValidationFailure> failures, object expectedCustomState)
Returns

System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>

Parameters
TypeName
System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>failures
System.ObjectexpectedCustomState

WithMessageArgument<T>(IEnumerable<ValidationFailure>, String, T)

View Source
Declaration
public static IEnumerable<ValidationFailure> WithMessageArgument<T>(this IEnumerable<ValidationFailure> failures, string argumentKey, T argumentValue)
Returns

System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>

Parameters
TypeName
System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>failures
System.StringargumentKey
<T>argumentValue
Type Parameters
  • T

WithErrorMessage(IEnumerable<ValidationFailure>, String)

View Source
Declaration
public static IEnumerable<ValidationFailure> WithErrorMessage(this IEnumerable<ValidationFailure> failures, string expectedErrorMessage)
Returns

System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>

Parameters
TypeName
System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>failures
System.StringexpectedErrorMessage

WithErrorCode(IEnumerable<ValidationFailure>, String)

View Source
Declaration
public static IEnumerable<ValidationFailure> WithErrorCode(this IEnumerable<ValidationFailure> failures, string expectedErrorCode)
Returns

System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>

Parameters
TypeName
System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>failures
System.StringexpectedErrorCode

WithoutSeverity(IEnumerable<ValidationFailure>, Severity)

View Source
Declaration
public static IEnumerable<ValidationFailure> WithoutSeverity(this IEnumerable<ValidationFailure> failures, Severity unexpectedSeverity)
Returns

System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>

Parameters
TypeName
System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>failures
ServiceStack.FluentValidation.SeverityunexpectedSeverity

WithoutCustomState(IEnumerable<ValidationFailure>, Object)

View Source
Declaration
public static IEnumerable<ValidationFailure> WithoutCustomState(this IEnumerable<ValidationFailure> failures, object unexpectedCustomState)
Returns

System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>

Parameters
TypeName
System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>failures
System.ObjectunexpectedCustomState

WithoutErrorMessage(IEnumerable<ValidationFailure>, String)

View Source
Declaration
public static IEnumerable<ValidationFailure> WithoutErrorMessage(this IEnumerable<ValidationFailure> failures, string unexpectedErrorMessage)
Returns

System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>

Parameters
TypeName
System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>failures
System.StringunexpectedErrorMessage

WithoutErrorCode(IEnumerable<ValidationFailure>, String)

View Source
Declaration
public static IEnumerable<ValidationFailure> WithoutErrorCode(this IEnumerable<ValidationFailure> failures, string unexpectedErrorCode)
Returns

System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>

Parameters
TypeName
System.Collections.Generic.IEnumerable<ServiceStack.FluentValidation.Results.ValidationFailure>failures
System.StringunexpectedErrorCode