Class ValidationErrorAssertions
Contains assertion methods for ValidationError types.
public class ValidationErrorAssertions : ReferenceTypeAssertions<ValidationError, ValidationErrorAssertions>
- Inheritance
-
ValidationErrorAssertions
- Inherited Members
- Extension Methods
Constructors
ValidationErrorAssertions(ValidationError)
Initializes a new instance of the ValidationErrorAssertions class.
public ValidationErrorAssertions(ValidationError error)
Parameters
errorValidationError
Properties
Identifier
Returns the type of the subject the assertion applies on. It should be a user-friendly name as it is included in the failure message.
protected override string Identifier { get; }
Property Value
Methods
HaveFieldCount(int, string, params object[])
Asserts that the validation error has the specified number of fields with errors.
public AndConstraint<ValidationErrorAssertions> HaveFieldCount(int expectedCount, string because = "", params object[] becauseArgs)
Parameters
expectedCountintThe expected number of fields with errors.
becausestringA formatted phrase explaining why the assertion is needed.
becauseArgsobject[]Zero or more objects to format using the placeholders in
because.
Returns
HaveFieldError(string, string, params object[])
Asserts that the validation error contains an error for the specified field.
public AndConstraint<ValidationErrorAssertions> HaveFieldError(string fieldName, string because = "", params object[] becauseArgs)
Parameters
fieldNamestringThe field name that should have an error.
becausestringA formatted phrase explaining why the assertion is needed.
becauseArgsobject[]Zero or more objects to format using the placeholders in
because.
Returns
HaveFieldErrorWithDetail(string, string, string, params object[])
Asserts that the validation error contains a specific detail for the specified field.
public AndConstraint<ValidationErrorAssertions> HaveFieldErrorWithDetail(string fieldName, string expectedDetail, string because = "", params object[] becauseArgs)
Parameters
fieldNamestringThe field name.
expectedDetailstringThe expected error detail for the field.
becausestringA formatted phrase explaining why the assertion is needed.
becauseArgsobject[]Zero or more objects to format using the placeholders in
because.