Table of Contents

Class ValidationErrorAssertions

Namespace
Trellis.Testing
Assembly
Trellis.Testing.dll

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

error ValidationError

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

string

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

expectedCount int

The expected number of fields with errors.

because string

A formatted phrase explaining why the assertion is needed.

becauseArgs object[]

Zero or more objects to format using the placeholders in because.

Returns

AndConstraint<ValidationErrorAssertions>

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

fieldName string

The field name that should have an error.

because string

A formatted phrase explaining why the assertion is needed.

becauseArgs object[]

Zero or more objects to format using the placeholders in because.

Returns

AndConstraint<ValidationErrorAssertions>

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

fieldName string

The field name.

expectedDetail string

The expected error detail for the field.

because string

A formatted phrase explaining why the assertion is needed.

becauseArgs object[]

Zero or more objects to format using the placeholders in because.

Returns

AndConstraint<ValidationErrorAssertions>