Public API Spies
Methods
SpiedMethod
sealedA spy on a void method: the real member runs, and each call the code under test makes that the selection matches is recorded. When it comes from a table, it covers its own instance only.
Every member throws InvalidOperationException once the test or fixture this spy belongs to has finished.
| CallList Calls { get; } | The calls recorded, in the order the code under test made them. |
|---|
SpiedMethod<TResult>
sealedA spy on a method with a result: the real member runs, and each call the code under test makes that the selection matches is recorded. When it comes from a table, it covers its own instance only.
Every member throws InvalidOperationException once the test or fixture this spy belongs to has finished.
| CallList<TResult> Calls { get; } | The calls recorded, in the order the code under test made them. |
|---|
SpiedMethodTable<TInstance>
sealedSpies on a void method on any instance: one spy per instance, reached by the instance.
Every member throws InvalidOperationException once the test or fixture this spy belongs to has finished.
| SpiedMethod this[TInstance instance] | The spy of one instance's calls. Throws ArgumentNullException when the instance is null. |
|---|---|
| CallList Calls { get; } | The calls recorded on every instance, in the order the code under test made them, each with its instance. |
SpiedMethodTable<TInstance, TResult>
sealedSpies on a method with a result on any instance: one spy per instance, reached by the instance.
Every member throws InvalidOperationException once the test or fixture this spy belongs to has finished.
| SpiedMethod<TResult> this[TInstance instance] | The spy of one instance's calls. Throws ArgumentNullException when the instance is null. |
|---|---|
| CallList<TResult> Calls { get; } | The calls recorded on every instance, in the order the code under test made them, each with its instance. |
Constructors
SpiedConstructor<TResult>
sealedA spy on a constructor: the real member runs, and each call the code under test makes that the selection matches is recorded.
Every member throws InvalidOperationException once the test or fixture this spy belongs to has finished.
| CallList<TResult> Calls { get; } | The calls recorded, in the order the code under test made them. |
|---|
Fields
SpiedField<TValue>
sealedA spy on a field: the real member is read and written, and each read and write the code under test makes that the selection matches is recorded. A selection through a chain follows the instance the chain reaches at each access; when it comes from a table, it covers its own instance only.
Every member throws InvalidOperationException once the test or fixture this spy belongs to has finished.
| AccessList<TValue> Reads { get; } | The reads recorded, in the order the code under test made them. |
|---|---|
| AccessList<TValue> Writes { get; } | The writes recorded, in the order the code under test made them. |
SpiedFieldTable<TInstance, TValue>
sealedSpies on a field on any instance: one spy per instance, reached by the instance.
Every member throws InvalidOperationException once the test or fixture this spy belongs to has finished.
| SpiedField<TValue> this[TInstance instance] | The spy of one instance. Throws ArgumentNullException when the instance is null. |
|---|---|
| AccessList<TValue> Reads { get; } | The reads recorded on every instance, in the order the code under test made them, each with its instance. |
| AccessList<TValue> Writes { get; } | The writes recorded on every instance, in the order the code under test made them, each with its instance. |
Properties
SpiedProperty<TValue>
sealedA spy on a property: the real member is read and written, and each read and write the code under test makes that the selection matches is recorded. A selection through a chain follows the instance the chain reaches at each access; when it comes from a table, it covers its own instance only.
Every member throws InvalidOperationException once the test or fixture this spy belongs to has finished.
| AccessList<TValue> Reads { get; } | The reads recorded, in the order the code under test made them. |
|---|---|
| AccessList<TValue> Writes { get; } | The writes recorded, in the order the code under test made them. |
SpiedPropertyTable<TInstance, TValue>
sealedSpies on a property on any instance: one spy per instance, reached by the instance.
Every member throws InvalidOperationException once the test or fixture this spy belongs to has finished.
| SpiedProperty<TValue> this[TInstance instance] | The spy of one instance. Throws ArgumentNullException when the instance is null. |
|---|---|
| AccessList<TValue> Reads { get; } | The reads recorded on every instance, in the order the code under test made them, each with its instance. |
| AccessList<TValue> Writes { get; } | The writes recorded on every instance, in the order the code under test made them, each with its instance. |
Indexers
SpiedIndexer<TValue>
sealedA spy on an element written with []: the real member is read and written, and each read and write the code under test makes that the selection matches is recorded. A selection through a chain follows the instance the chain reaches at each access; when it comes from a table, it covers its own instance only.
Every member throws InvalidOperationException once the test or fixture this spy belongs to has finished.
| AccessList<TValue> Reads { get; } | The reads recorded, in the order the code under test made them. |
|---|---|
| AccessList<TValue> Writes { get; } | The writes recorded, in the order the code under test made them. |
SpiedIndexerTable<TInstance, TValue>
sealedSpies on an element written with [] on any instance: one spy per instance, reached by the instance.
Every member throws InvalidOperationException once the test or fixture this spy belongs to has finished.
| SpiedIndexer<TValue> this[TInstance instance] | The spy of one instance. Throws ArgumentNullException when the instance is null. |
|---|---|
| AccessList<TValue> Reads { get; } | The reads recorded on every instance, in the order the code under test made them, each with its instance. |
| AccessList<TValue> Writes { get; } | The writes recorded on every instance, in the order the code under test made them, each with its instance. |
Events
SpiedEvent
sealedA spy on an event: the real event keeps its handlers, and the spy records the handlers the code under test subscribes and the raises it makes. Handlers are kept per instance: a selection through a chain follows the instance the chain reaches at each access; when it comes from a table, it covers its own instance only.
Every member throws InvalidOperationException once the test or fixture this spy belongs to has finished.
| IReadOnlyList<RecordedHandler> Handlers { get; } | The handlers the code under test subscribed while this spy exists and has not unsubscribed, in subscription order. |
|---|---|
| IReadOnlyList<RecordedInvocation> Invocations { get; } | The raises the code under test made, in order. |
SpiedEventTable<TInstance>
sealedSpies on an event on any instance: one spy per instance, reached by the instance.
Every member throws InvalidOperationException once the test or fixture this spy belongs to has finished.
| SpiedEvent this[TInstance instance] | The spy of one instance's event. Throws ArgumentNullException when the instance is null. |
|---|---|
| IReadOnlyList<RecordedHandler> Handlers { get; } | The handlers the code under test subscribed on every instance and has not unsubscribed, in subscription order, each with its instance. |
| IReadOnlyList<RecordedInvocation> Invocations { get; } | The raises the code under test made on every instance, in order, each with its instance. |
Catch blocks
SpiedCatch<TException>
sealedA spy on catch blocks: it records every catch block the code under test enters with an exception of its type, subtypes included, while it exists. TException derives from Exception.
Every member throws InvalidOperationException once the test or fixture this spy belongs to has finished.
| IReadOnlyList<RecordedCatch> Catches { get; } | The catch blocks entered, in order. |
|---|