Calls

CallList

sealed

The calls a spy or stub recorded, in the order the code under test made them, as an IReadOnlyList<RecordedCall>. The list is live: it grows as the code under test runs.

Members
int Count { get; }The number of calls recorded.
RecordedCall this[int index]The call at this position. Throws ArgumentOutOfRangeException when the index is negative, or not less than Count.
IEnumerator<RecordedCall> GetEnumerator()Enumerates the calls recorded so far.

CallList<TResult>

sealed

The calls a spy or stub recorded, in the order the code under test made them, each with its result, as an IReadOnlyList<RecordedCall<TResult>>. The list is live: it grows as the code under test runs.

Members
int Count { get; }The number of calls recorded.
RecordedCall<TResult> this[int index]The call at this position. Throws ArgumentOutOfRangeException when the index is negative, or not less than Count.
IReadOnlyList<TResult> Results { get; }The results of the calls recorded, in order.
IEnumerator<RecordedCall<TResult>> GetEnumerator()Enumerates the calls recorded so far.

RecordedCall

class

What a spy or stub recorded of one call the code under test made to a method or a constructor.

Members
object Instance { get; }The object the method was called on, or null for a static method or a constructor.
IReadOnlyList<object> Arguments { get; }The arguments, ordered as the parameters are in the selection, with out and ref values as the call left them.
Exception Exception { get; }The exception the call threw, or null when it returned.
int Order { get; }The sequence number of this call, access, raise or catch, shared by every spy, stub and fake in the test: the doubles that record the same one give it the same number.
string ToString()The call as one line written the way the code reads, its outcome, the caller's source line and the order: Player.TakeDamage(5) returned 45 Player.cs:42 #7.

RecordedCall<TResult>

sealed

What a spy or stub recorded of one call the code under test made to a method with a result, or to a constructor. It inherits every member of RecordedCall, and adds the result.

Members
TResult Result { get; }What the call returned, or the object a constructor built; the type's default when the call threw.

Reads and writes

AccessList<TValue>

sealed

The reads or writes a spy, stub or fake recorded, in the order the code under test made them, as an IReadOnlyList<RecordedAccess<TValue>>. The list is live: it grows as the code under test runs.

Members
int Count { get; }The number of accesses recorded.
RecordedAccess<TValue> this[int index]The access at this position. Throws ArgumentOutOfRangeException when the index is negative, or not less than Count.
IReadOnlyList<TValue> Contents { get; }What each access read or wrote, in order.
IEnumerator<RecordedAccess<TValue>> GetEnumerator()Enumerates the accesses recorded so far.

RecordedAccess<TValue>

sealed

What a spy, stub or fake recorded of one read or write the code under test made to a field, a property or an element written with [].

Members
object Instance { get; }The object the member was reached through, or null for a static member. For an array element, the array.
IReadOnlyList<object> Arguments { get; }The indices of an element written with [], ordered as in the selection; empty for a field or property.
TValue Content { get; }What the read got or the write carried. The type's default when a read threw; a write that threw keeps the value it tried to write.
Exception Exception { get; }The exception the read or write threw, or null when it completed.
int Order { get; }The sequence number of this call, access, raise or catch, shared by every spy, stub and fake in the test: the doubles that record the same one give it the same number.
string ToString()The access as one line written the way the code reads, the caller's source line and the order: Player.health written 50 (faked) Player.cs:18 #8.

Events

RecordedHandler

sealed

A handler the code under test subscribed to an event and has not unsubscribed.

Members
object Instance { get; }The object whose event the handler is subscribed to, or null for a static event.
Delegate Handler { get; }The handler.
int Order { get; }The sequence number of the subscription, shared by every spy, stub and fake in the test, calls and accesses alike.
string ToString()The handler as the subscription reads, the subscriber's source line and the order: Player.Died += Hud.OnDied Hud.cs:12 #3.

RecordedInvocation

sealed

What a spy or fake recorded of one raise of the event by the code under test.

Members
object Instance { get; }The object that raised its event, or null for a static event.
IReadOnlyList<object> Arguments { get; }The arguments the event was raised with, ordered as the delegate's parameters. Throws InvalidOperationException when no handler was subscribed at the raise, so C# never evaluated its arguments.
bool HadHandlers { get; }Whether a handler was subscribed when the code under test raised the event. With none, C# skips the raise and never evaluates its arguments, so Arguments has none to give.
int Order { get; }The sequence number of this call, access, raise or catch, shared by every spy, stub and fake in the test: the doubles that record the same one give it the same number.
string ToString()The raise as one line: the event, the arguments, the caller's source line and the order: Player.Died raised(5) Player.cs:30 #4.

Catch blocks

RecordedCatch

sealed

What a catch spy recorded of one catch block the code under test entered. Explained in Spy on caught exceptions.

Members
Exception Exception { get; }The exception the catch block caught.
Exception Rethrown { get; }The exception that left the catch block: the caught one for throw;, another for a wrapping throw, or null when the block handled it.
MethodBase Method { get; }The method holding the catch block, as written: an async method or an iterator, not the state machine the compiler generates for it.
int Line { get; }The source line of the catch block, or 0 when the assembly has no symbols.
int Order { get; }The sequence number of this call, access, raise or catch, shared by every spy, stub and fake in the test: the doubles that record the same one give it the same number.
string ToString()The catch as one line: the exception, where it was caught, what left the block, the catch block's source line and the order: IOException: disk full caught in SaveSystem.Save, handled SaveSystem.cs:21 #5.