Class Trapture<T>
- Namespace
- Mokkit
- Assembly
- Mokkit.dll
TRansparent cAPTURE — a value capture that converts implicitly to the captured type, so it can be
passed wherever a T is expected without reading Mokkit.Trapture`1.Value explicitly.
Use this when the captured value flows transparently into later Arrange/Act steps; use
Mokkit.Capture`1 instead when you want to force an explicit .Value read.
public class Trapture<T> : ICapture<T>, ICaptureInitializer<T>Type Parameters
T-
The type of value to capture.
Inheritance
Implements
Inherited Members
Properties
EnsureValue
Gets the captured value, guarded — trapture.EnsureValue instead of
trapture.Value!. Fails loudly when the capture is unfilled or its value is empty.
public T EnsureValue { get; }Property Value
- T
Exceptions
- InvalidOperationException
-
Thrown when the capture is unfilled or its value is empty.
Value
Gets the captured value.
public T? Value { get; }Property Value
- T?
Methods
Prop<TProp>(Func<T, TProp>)
Reads a member off the captured value — message.Prop(m => m.ClientId) instead of
message.Value!.ClientId. Useful even here, where the implicit conversion covers whole-value
reads but not member reads.
public TProp? Prop<TProp>(Func<T, TProp> propFn)Parameters
propFnFunc<T, TProp>-
Projects the member from the (non-null) captured value.
Returns
- TProp?
-
The projected member, which may itself be
nullif the member is nullable.
Type Parameters
TProp-
The type of the member being read.
Exceptions
- ArgumentNullException
-
Thrown when
propFnisnull. - InvalidOperationException
-
Thrown when the trapture has not been initialized with a value.
Operators
implicit operator T(Trapture<T>)
Provides implicit conversion from Mokkit.Trapture`1 to the captured type.
public static implicit operator T(Trapture<T> trapture)Parameters
traptureTrapture<T>-
The trapture instance to convert.
Returns
- T
-
The captured value.
Exceptions
- InvalidOperationException
-
Thrown when the trapture has not been initialized with a value.