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 EnsureInspectExtensionsInheritance
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
inspectITestInspect-
The inspect chain.
valueT-
The already-materialized value (e.g.
result.ClientId!.Value). capturedT-
Receives the validated value.
becausestring?-
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 : structParameters
inspectITestInspect-
The inspect chain.
sourceTSource-
The source object to project from.
selectorFunc<TSource, T?>-
Projects a nullable value from the source (e.g.
r => r.ClientId). capturedT-
Receives the unwrapped, validated value.
becausestring?-
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.