Mocker..::..AddType<(Of <(<'TInterface, TClass>)>)> Method (Func<(Of <(<'Mocker, TClass>)>)>, Boolean, array<Object>[]()[][])

Adds an interface to Class mapping to the typeMap for easier resolution.

Namespace:  FastMoq
Assembly:  FastMoq.Core (in FastMoq.Core.dll)

Syntax


public void AddType<TInterface, TClass>(
	Func<Mocker, TClass> createFunc,
	bool replace,
	params Object[] args
)
Public Sub AddType(Of TInterface, TClass) ( _
	createFunc As Func(Of Mocker, TClass), _
	replace As Boolean, _
	ParamArray args As Object() _
)
public:
generic<typename TInterface, typename TClass>
void AddType(
	Func<Mocker^, TClass>^ createFunc, 
	bool^ replace, 
	... array<Object^>^ args
)

Type Parameters

TInterface
The interface or class Type which can be mapped to a specific Class.
TClass
The Class Type (cannot be an interface) that can be created and assigned to TInterface />.

Parameters

createFunc
Type: Func<(Of <(<'Mocker, TClass>)>)>
An optional create function used to create the class.
replace
Type: Boolean
Replace type if already exists. Default: false.
args
Type: array<Object>[]()[][]
arguments needed in model.

Exceptions


ExceptionCondition
ArgumentException$"{typeof(TClass).Name} cannot be an interface."
ArgumentException$"{typeof(TClass).Name} is not assignable to {typeof(TInterface).Name}."