Methods

StubbedMethod

sealed

A stub of a void method: the real member never runs, and each call the code under test makes that the selection matches is recorded. With nothing declared, a call does nothing. When it comes from a table, it covers its own instance only.

Every member throws InvalidOperationException once the test or fixture this stub belongs to has finished. A method that takes an answer throws ArgumentNullException when it is null, and ArgumentException when its parameters fit none of the forms its row lists.

Members
CallList Calls { get; }The calls recorded, in the order the code under test made them.
StubbedMethod Do(Action replacement)Replaces the call. The answer takes no parameters or the call's arguments. A throw in it makes the call throw. It replaces any previous answer. Overloads take up to 16 parameters.

StubbedMethod<TResult>

sealed

A stub of a method with a result: the real member never runs, and each call the code under test makes that the selection matches is recorded. With nothing declared, a call returns the type's default. When it comes from a table, it covers its own instance only.

Every member throws InvalidOperationException once the test or fixture this stub belongs to has finished. A method that takes an answer throws ArgumentNullException when it is null, and ArgumentException when its parameters fit none of the forms its row lists.

Members
CallList<TResult> Calls { get; }The calls recorded, in the order the code under test made them.
StubbedMethod<TResult> Returns(TResult value, params TResult[] then)Returns these results, one per matched call on each instance; the last one repeats. It replaces any previous answer. Throws ArgumentNullException when the second value is a null without a cast, as in Returns(value, null): write (T)null.
StubbedMethod<TResult> Returns(Func<TResult> compute)Returns a computed result. The answer takes no parameters or the call's arguments. A throw in it makes the call throw. It replaces any previous answer. Overloads take up to 16 parameters.

StubbedMethodTable<TInstance>

sealed

Stubs a void method on any instance: one stub per instance, reached by the instance. An answer set through the table serves every instance, existing and future, until one is set for a single instance; the last one set wins.

Every member throws InvalidOperationException once the test or fixture this stub belongs to has finished. A method that takes an answer throws ArgumentNullException when it is null, and ArgumentException when its parameters fit none of the forms its row lists.

Members
StubbedMethod this[TInstance instance]The stub 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.
StubbedMethodTable<TInstance> EachDo(Action replacement)Replaces the call on every instance. The answer takes no parameters, the call's arguments, or the instance then the arguments. A throw in it makes the call throw. It replaces any previous answer, for every instance. Overloads take up to 16 parameters.

StubbedMethodTable<TInstance, TResult>

sealed

Stubs a method with a result on any instance: one stub per instance, reached by the instance. An answer set through the table serves every instance, existing and future, until one is set for a single instance; the last one set wins.

Every member throws InvalidOperationException once the test or fixture this stub belongs to has finished. A method that takes an answer throws ArgumentNullException when it is null, and ArgumentException when its parameters fit none of the forms its row lists.

Members
StubbedMethod<TResult> this[TInstance instance]The stub 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.
StubbedMethodTable<TInstance, TResult> EachReturns(TResult value, params TResult[] then)Returns these results on every instance, each instance with its own sequence; the last one repeats. It replaces any previous answer, for every instance. Throws ArgumentNullException when the second value is a null without a cast, as in Returns(value, null): write (T)null.
StubbedMethodTable<TInstance, TResult> EachReturns(Func<TResult> compute)Returns a computed result on every instance. The answer takes no parameters, the call's arguments, or the instance then the arguments. A throw in it makes the call throw. It replaces any previous answer, for every instance. Overloads take up to 16 parameters.

Constructors

StubbedConstructor<TResult>

sealed

A stub of a constructor: the real member never runs, and each call the code under test makes that the selection matches is recorded. With nothing declared, a call returns null.

Every member throws InvalidOperationException once the test or fixture this stub belongs to has finished. A method that takes an answer throws ArgumentNullException when it is null, and ArgumentException when its parameters fit none of the forms its row lists.

Members
CallList<TResult> Calls { get; }The calls recorded, in the order the code under test made them.
StubbedConstructor<TResult> Returns(TResult value, params TResult[] then)Returns these results, one per matched call; the last one repeats. It replaces any previous answer. Throws ArgumentNullException when the second value is a null without a cast, as in Returns(value, null): write (T)null.
StubbedConstructor<TResult> Returns(Func<TResult> compute)Returns a computed result. The answer takes no parameters or the call's arguments. A throw in it makes the call throw. It replaces any previous answer. Overloads take up to 16 parameters.

Fields

StubbedField<TValue>

sealed

A stub of a field: the real member is never read or written. Returns decides what reads return and Do what writes do; with nothing declared, a read returns the type's default and a write does nothing. 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 stub belongs to has finished. A method that takes an answer throws ArgumentNullException when it is null, and ArgumentException when its parameters fit none of the forms its row lists.

Members
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.
StubbedField<TValue> Returns(TValue value, params TValue[] then)Reads return these values, one per read on each instance; the last one repeats. It replaces any previous answer on reads. Throws ArgumentNullException when the second value is a null without a cast, as in Returns(value, null): write (T)null.
StubbedField<TValue> Returns(Func<TValue> compute)Reads return a computed value. The answer takes no parameters. A throw in it makes the read throw. It replaces any previous answer on reads.
StubbedField<TValue> Do(Action replacement)Replaces writes. The answer takes no parameters or the value written. A throw in it makes the write throw. It replaces any previous answer on writes.
StubbedField<TValue> Do(Action<TValue> replacement)Replaces writes. The answer takes no parameters or the value written. A throw in it makes the write throw. It replaces any previous answer on writes.

StubbedFieldTable<TInstance, TValue>

sealed

Stubs a field on any instance: one stub per instance, reached by the instance. An answer set through the table serves every instance, existing and future, until one is set for a single instance; the last one set wins.

Every member throws InvalidOperationException once the test or fixture this stub belongs to has finished. A method that takes an answer throws ArgumentNullException when it is null, and ArgumentException when its parameters fit none of the forms its row lists.

Members
StubbedField<TValue> this[TInstance instance]The stub 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.
StubbedFieldTable<TInstance, TValue> EachReturns(TValue value, params TValue[] then)Reads on every instance return these values, each instance with its own sequence; the last one repeats. It replaces any previous answer on reads, for every instance. Throws ArgumentNullException when the second value is a null without a cast, as in Returns(value, null): write (T)null.
StubbedFieldTable<TInstance, TValue> EachReturns(Func<TValue> compute)Reads on every instance return a computed value. The answer takes no parameters or the instance. A throw in it makes the read throw. It replaces any previous answer on reads, for every instance.
StubbedFieldTable<TInstance, TValue> EachReturns(Func<TInstance, TValue> compute)Reads on every instance return a computed value. The answer takes no parameters or the instance. A throw in it makes the read throw. It replaces any previous answer on reads, for every instance.
StubbedFieldTable<TInstance, TValue> EachDo(Action replacement)Replaces writes on every instance. The answer takes no parameters, the value written, or the instance then the value. A throw in it makes the write throw. It replaces any previous answer on writes, for every instance.
StubbedFieldTable<TInstance, TValue> EachDo(Action<TValue> replacement)Replaces writes on every instance. The answer takes no parameters, the value written, or the instance then the value. A throw in it makes the write throw. It replaces any previous answer on writes, for every instance.
StubbedFieldTable<TInstance, TValue> EachDo(Action<TInstance, TValue> replacement)Replaces writes on every instance. The answer takes no parameters, the value written, or the instance then the value. A throw in it makes the write throw. It replaces any previous answer on writes, for every instance.

Properties

StubbedProperty<TValue>

sealed

A stub of a property: the real member is never read or written. Returns decides what reads return and Do what writes do; with nothing declared, a read returns the type's default and a write does nothing. 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 stub belongs to has finished. A method that takes an answer throws ArgumentNullException when it is null, and ArgumentException when its parameters fit none of the forms its row lists.

Members
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.
StubbedProperty<TValue> Returns(TValue value, params TValue[] then)Reads return these values, one per read on each instance; the last one repeats. It replaces any previous answer on reads. Throws ArgumentNullException when the second value is a null without a cast, as in Returns(value, null): write (T)null.
StubbedProperty<TValue> Returns(Func<TValue> compute)Reads return a computed value. The answer takes no parameters. A throw in it makes the read throw. It replaces any previous answer on reads.
StubbedProperty<TValue> Do(Action replacement)Replaces writes. The answer takes no parameters or the value written. A throw in it makes the write throw. It replaces any previous answer on writes.
StubbedProperty<TValue> Do(Action<TValue> replacement)Replaces writes. The answer takes no parameters or the value written. A throw in it makes the write throw. It replaces any previous answer on writes.

StubbedPropertyTable<TInstance, TValue>

sealed

Stubs a property on any instance: one stub per instance, reached by the instance. An answer set through the table serves every instance, existing and future, until one is set for a single instance; the last one set wins.

Every member throws InvalidOperationException once the test or fixture this stub belongs to has finished. A method that takes an answer throws ArgumentNullException when it is null, and ArgumentException when its parameters fit none of the forms its row lists.

Members
StubbedProperty<TValue> this[TInstance instance]The stub 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.
StubbedPropertyTable<TInstance, TValue> EachReturns(TValue value, params TValue[] then)Reads on every instance return these values, each instance with its own sequence; the last one repeats. It replaces any previous answer on reads, for every instance. Throws ArgumentNullException when the second value is a null without a cast, as in Returns(value, null): write (T)null.
StubbedPropertyTable<TInstance, TValue> EachReturns(Func<TValue> compute)Reads on every instance return a computed value. The answer takes no parameters or the instance. A throw in it makes the read throw. It replaces any previous answer on reads, for every instance.
StubbedPropertyTable<TInstance, TValue> EachReturns(Func<TInstance, TValue> compute)Reads on every instance return a computed value. The answer takes no parameters or the instance. A throw in it makes the read throw. It replaces any previous answer on reads, for every instance.
StubbedPropertyTable<TInstance, TValue> EachDo(Action replacement)Replaces writes on every instance. The answer takes no parameters, the value written, or the instance then the value. A throw in it makes the write throw. It replaces any previous answer on writes, for every instance.
StubbedPropertyTable<TInstance, TValue> EachDo(Action<TValue> replacement)Replaces writes on every instance. The answer takes no parameters, the value written, or the instance then the value. A throw in it makes the write throw. It replaces any previous answer on writes, for every instance.
StubbedPropertyTable<TInstance, TValue> EachDo(Action<TInstance, TValue> replacement)Replaces writes on every instance. The answer takes no parameters, the value written, or the instance then the value. A throw in it makes the write throw. It replaces any previous answer on writes, for every instance.

Indexers

StubbedIndexer<TValue>

sealed

A stub of an element written with []: the real member is never read or written. Returns decides what reads return and Do what writes do; with nothing declared, a read returns the type's default and a write does nothing. 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 stub belongs to has finished. A method that takes an answer throws ArgumentNullException when it is null, and ArgumentException when its parameters fit none of the forms its row lists.

Members
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.
StubbedIndexer<TValue> Returns(TValue value, params TValue[] then)Reads return these values, one per read on each instance; the last one repeats. It replaces any previous answer on reads. Throws ArgumentNullException when the second value is a null without a cast, as in Returns(value, null): write (T)null.
StubbedIndexer<TValue> Returns(Func<TValue> compute)Reads return a computed value. The answer takes no parameters or the indices. A throw in it makes the read throw. It replaces any previous answer on reads. Overloads take up to 16 parameters.
StubbedIndexer<TValue> Do(Action replacement)Replaces writes. The answer takes no parameters, or the indices then the value written. A throw in it makes the write throw. It replaces any previous answer on writes. Overloads take up to 16 parameters.

StubbedIndexerTable<TInstance, TValue>

sealed

Stubs an element written with [] on any instance: one stub per instance, reached by the instance. An answer set through the table serves every instance, existing and future, until one is set for a single instance; the last one set wins.

Every member throws InvalidOperationException once the test or fixture this stub belongs to has finished. A method that takes an answer throws ArgumentNullException when it is null, and ArgumentException when its parameters fit none of the forms its row lists.

Members
StubbedIndexer<TValue> this[TInstance instance]The stub 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.
StubbedIndexerTable<TInstance, TValue> EachReturns(TValue value, params TValue[] then)Reads on every instance return these values, each instance with its own sequence; the last one repeats. It replaces any previous answer on reads, for every instance. Throws ArgumentNullException when the second value is a null without a cast, as in Returns(value, null): write (T)null.
StubbedIndexerTable<TInstance, TValue> EachReturns(Func<TValue> compute)Reads on every instance return a computed value. The answer takes no parameters, the indices, or the instance then the indices. A throw in it makes the read throw. It replaces any previous answer on reads, for every instance. Overloads take up to 16 parameters.
StubbedIndexerTable<TInstance, TValue> EachDo(Action replacement)Replaces writes on every instance. The answer takes no parameters, the indices then the value written, or the instance then the indices and the value. A throw in it makes the write throw. It replaces any previous answer on writes, for every instance. Overloads take up to 16 parameters.