Table of Contents

Class EnsureInspectExtensions

Namespace
Mokkit.Inspect
Assembly
Mokkit.dll

Ensure helpers for the Inspect phase. Because the source is already materialized during Inspect, these guard the value and capture it eagerly (synchronously) so later chained steps can consume the captured value directly. They apply to value scopes too, since Mokkit.Inspect.ITestInspectScope`1 derives from Mokkit.Inspect.ITestInspect.

public static class EnsureInspectExtensions

Inheritance

Inherited Members

Methods

Ensure<T>(ITestInspect, T, out T, string?)

Guards value as non-empty and captures it into captured for reuse in later chained inspect steps.

public static ITestInspect Ensure<T>(this ITestInspect inspect, T value, out T captured, string? because = null)

Parameters

inspect ITestInspect

The inspect chain.

value T

The already-materialized value (e.g. result.ClientId!.Value).

captured T

Receives the validated value.

because string?

Optional context appended to the failure message.

Returns

ITestInspect

The inspect chain for fluent chaining.

Type Parameters

T

The value type.

Exceptions

InvalidOperationException

Thrown when the value is empty.

Ensure<TSource, T>(ITestInspect, TSource, Func<TSource, T?>, out T, string?)

Projects a nullable value from source, guards that it has a non-empty value, and captures the unwrapped result — removing the !.Value noise for nullable-struct members (e.g. a Guid? id).

public static ITestInspect Ensure<TSource, T>(this ITestInspect inspect, TSource source, Func<TSource, T?> selector, out T captured, string? because = null) where T : struct

Parameters

inspect ITestInspect

The inspect chain.

source TSource

The source object to project from.

selector Func<TSource, T?>

Projects a nullable value from the source (e.g. r => r.ClientId).

captured T

Receives the unwrapped, validated value.

because string?

Optional context appended to the failure message.

Returns

ITestInspect

The inspect chain for fluent chaining.

Type Parameters

TSource

The source object type.

T

The unwrapped value type.

Exceptions

InvalidOperationException

Thrown when the projected value is null or empty.