Class InstanceFunction<T>
Stores a strongly typed factory delegate that creates instances of T.
Inherited Members
Namespace: FastMoq.Models
Assembly: FastMoq.Core.dll
Syntax
public class InstanceFunction<T> : InstanceFunction
Type Parameters
| Name | Description |
|---|---|
| T | The runtime type produced by the stored factory delegate. |
Constructors
InstanceFunction()
Initializes an empty instance function for T.
Declaration
public InstanceFunction()
InstanceFunction(Func<Mocker, object?, T?>)
Initializes the instance function with a factory that accepts the current Mocker and one extra parameter value.
Declaration
public InstanceFunction(Func<Mocker, object?, T?> doubleParamFunc)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<Mocker, object, T> | doubleParamFunc | The factory delegate to invoke when one extra parameter value is supplied. |
InstanceFunction(Func<Mocker, T?>)
Initializes the instance function with a factory that accepts only the current Mocker.
Declaration
public InstanceFunction(Func<Mocker, T?> singleParamFunc)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<Mocker, T> | singleParamFunc | The factory delegate to invoke when no extra parameter value is supplied. |
Methods
Invoke(Mocker, params object?[]?)
Invokes the stored strongly typed factory delegate.
Declaration
public T? Invoke(Mocker mocker, params object?[]? parameters)
Parameters
| Type | Name | Description |
|---|---|---|
| Mocker | mocker | The active mocker used as the first delegate argument. |
| object[] | parameters | Optional extra parameters passed to delegates that accept a second argument. |
Returns
| Type | Description |
|---|---|
| T | The created instance, or null when the stored delegate returns null. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown when no compatible delegate has been assigned. |