Table of Contents

Class Capture<T>

Namespace
Mokkit
Assembly
Mokkit.dll

Represents a type-safe, explicit value capture used to carry a value produced during one test phase into a later one. Unlike Mokkit.Trapture`1, this type does not convert implicitly to the captured type — consumers must read Mokkit.Capture`1.Value explicitly, forcing the intent to be visible at the use site.

public class Capture<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 — capture.EnsureValue instead of capture.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 — client.Prop(c => c.Id) instead of client.Value!.Id.

public TProp? Prop<TProp>(Func<T, TProp> propFn)

Parameters

propFn Func<T, TProp>

Projects the member from the (non-null) captured value.

Returns

TProp?

The projected member, which may itself be null if the member is nullable.

Type Parameters

TProp

The type of the member being read.

Exceptions

ArgumentNullException

Thrown when propFn is null.

InvalidOperationException

Thrown when the capture has not been initialized with a value.