Table of Contents

Testing a validation rule

When creating the validation rule, a test class is automatically created. This class inherits from ValidationRuleTest<TValidationRule, TEntityView> or ValidationRuleTest<TValidationRule, TEntity>.

Executing the validation rule in a test

To execute the validation rule, you must simply call ExecuteValidationRuleAsync like in the following example:

// If the validation rule is asynchronous you must call the method with a CancellationToken
IValidationRuleResult result = await ExecuteValidationRuleAsync(item, CancellationToken.None);

//If the validation rule is synchronous you must call the method without the CancellationToken
IValidationRuleResult result = await ExecuteValidationRuleAsync(item);