Table of Contents

Class IResultAssertions

Namespace
Trellis.Testing
Assembly
Trellis.Testing.dll

Contains assertion methods for the non-generic IResult interface. Mirrors the failure-side surface of ResultAssertions<TValue> (no success-value assertions exist because IResult carries no typed value).

public class IResultAssertions : ReferenceTypeAssertions<IResult, IResultAssertions>
Inheritance
IResultAssertions
Inherited Members
Extension Methods

Constructors

IResultAssertions(IResult?)

Initializes a new instance of the IResultAssertions class.

public IResultAssertions(IResult? result)

Parameters

result IResult

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

BeFailure(string, params object[])

Asserts that the result is a failure.

public AndWhichConstraint<IResultAssertions, Error> BeFailure(string because = "", params object[] becauseArgs)

Parameters

because string
becauseArgs object[]

Returns

AndWhichConstraint<IResultAssertions, Error>

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

Asserts that the result is a failure with a specific error type.

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

Parameters

because string
becauseArgs object[]

Returns

AndWhichConstraint<IResultAssertions, TError>

Type Parameters

TError

The expected error type.

Remarks

Wrong-type behavior mirrors BeFailureOfType<TError>(string, params object[]): without an active AssertionScope the assertion throws immediately; with an active scope it records the failure and returns default(TError)! so the scope's eventual Dispose surfaces the recorded assertion rather than a chained NullReferenceException.

BeSuccess(string, params object[])

Asserts that the result is a success.

public AndConstraint<IResultAssertions> BeSuccess(string because = "", params object[] becauseArgs)

Parameters

because string
becauseArgs object[]

Returns

AndConstraint<IResultAssertions>

HaveErrorCode(string, string, params object[])

Asserts that the failure has a specific error code.

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

Parameters

expectedCode string
because string
becauseArgs object[]

Returns

AndConstraint<IResultAssertions>

HaveErrorDetail(string, string, params object[])

Asserts that the failure has a specific error detail.

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

Parameters

expectedDetail string
because string
becauseArgs object[]

Returns

AndConstraint<IResultAssertions>

HaveErrorDetailContaining(string, string, params object[])

Asserts that the failure error detail contains the specified substring.

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

Parameters

substring string
because string
becauseArgs object[]

Returns

AndConstraint<IResultAssertions>