Table of Contents

Class ErrorAssertions

Namespace
Trellis.Testing
Assembly
Trellis.Testing.dll

Contains assertion methods for Error types.

public class ErrorAssertions : ReferenceTypeAssertions<Error, ErrorAssertions>
Inheritance
ErrorAssertions
Inherited Members
Extension Methods

Constructors

ErrorAssertions(Error)

Initializes a new instance of the ErrorAssertions class.

public ErrorAssertions(Error error)

Parameters

error Error

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

Be(Error, string, params object[])

Asserts that the error equals the expected error (based on Error.Equals which compares by Code).

public AndConstraint<ErrorAssertions> Be(Error expected, string because = "", params object[] becauseArgs)

Parameters

expected Error

The expected 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<ErrorAssertions>

BeOfType<TError>(string, params object[])

Asserts that the error is of the specified type and returns a typed constraint for further assertions.

public AndWhichConstraint<ErrorAssertions, TError> BeOfType<TError>(string because = "", params object[] becauseArgs) where TError : Error

Parameters

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

AndWhichConstraint<ErrorAssertions, TError>

Type Parameters

TError

The expected error type.

HaveCode(string, string, params object[])

Asserts that the error has the specified code.

public AndConstraint<ErrorAssertions> HaveCode(string expectedCode, string because = "", params object[] becauseArgs)

Parameters

expectedCode string

The expected error code.

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<ErrorAssertions>

HaveDetail(string, string, params object[])

Asserts that the error has the specified detail message.

public AndConstraint<ErrorAssertions> HaveDetail(string expectedDetail, string because = "", params object[] becauseArgs)

Parameters

expectedDetail string

The expected error detail.

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<ErrorAssertions>

HaveDetailContaining(string, string, params object[])

Asserts that the error detail contains the specified substring.

public AndConstraint<ErrorAssertions> HaveDetailContaining(string substring, string because = "", params object[] becauseArgs)

Parameters

substring string

The substring to search for.

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<ErrorAssertions>

HaveInstance(string, string, params object[])

Asserts that the error has the specified instance identifier.

public AndConstraint<ErrorAssertions> HaveInstance(string expectedInstance, string because = "", params object[] becauseArgs)

Parameters

expectedInstance string

The expected instance identifier.

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<ErrorAssertions>