Table of Contents

Class ValidationErrorAssertions

Namespace
Trellis.Testing
Assembly
Trellis.Testing.dll

Contains assertion methods for Error.UnprocessableContent.

public class ValidationErrorAssertions : ReferenceTypeAssertions<Error.UnprocessableContent, ValidationErrorAssertions>
Inheritance
ValidationErrorAssertions
Inherited Members
Extension Methods

Constructors

ValidationErrorAssertions(UnprocessableContent)

Initializes a new instance of the ValidationErrorAssertions class.

public ValidationErrorAssertions(Error.UnprocessableContent error)

Parameters

error Error.UnprocessableContent

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 error has the specified number of distinct field paths with violations.

public AndConstraint<ValidationErrorAssertions> HaveFieldCount(int expectedCount, string because = "", params object[] becauseArgs)

Parameters

expectedCount int

The expected number of distinct fields with violations.

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 error contains a field violation for the specified field.

public AndConstraint<ValidationErrorAssertions> HaveFieldError(string fieldName, string because = "", params object[] becauseArgs)

Parameters

fieldName string

The field name (plain or JSON pointer form, e.g. "email" or "/email").

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 error contains a field violation with the specified 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>