Table of Contents

Class IResultAssertionsExtensions

Namespace
Trellis.Testing
Assembly
Trellis.Testing.dll

FluentAssertions extension for IResult (the non-generic Trellis result interface). Lets tests call .Should().BeSuccess() / .Should().BeFailure() against members typed as IResult — most commonly Authorize(Actor, TResource) and Authorize(Actor, IReadOnlyList<TOwner>), which both return IResult by contract.

public static class IResultAssertionsExtensions
Inheritance
IResultAssertionsExtensions
Inherited Members

Examples

Receivers statically typed as IResult, IResult<TValue>, or any other type that only satisfies the IResult contract bind to this non-generic entry point because the typed extension is only declared on the concrete Result<TValue> struct. Consumers holding IResult<TValue> who want .HaveValue-style typed assertions should narrow the receiver to a concrete Result<TValue> first.

Remarks

The typed ResultAssertions<TValue> entry point continues to apply for concrete Result<TValue> values via the existing Should<TValue>(Result<TValue>) extension — Result<T> is a struct, more specific than the IResult interface, so overload resolution prefers the typed extension at the call site.

Methods

Should(IResult?)

Returns an assertions object for fluent assertions on the non-generic IResult interface. Accepts null so that a null receiver surfaces as a clean FluentAssertions failure ("Expected result to not be <null>") rather than a NullReferenceException from the first assertion call.

public static IResultAssertions Should(this IResult? result)

Parameters

result IResult

Returns

IResultAssertions