Gets or Creates then Initializes the specified Mock of T.
Namespace:
FastMoq
Assembly:
FastMoq.Core (in FastMoq.Core.dll)
public Mock<T> Initialize<T>(
Action<Mock<T>> action,
bool reset
)
Public Function Initialize(Of T) ( _
action As Action(Of Mock(Of T)), _
reset As Boolean _
) As Mock(Of T)
public:
generic<typename T>
Mock<T>^ Initialize(
Action<Mock<T>^>^ action,
bool^ reset
)
Type Parameters
- T
- The Mock Type, usually an interface.
Parameters
- action
- Type: Action<(Of <(<'Mock<(Of <(<'T>)>)>>)>)>
The action.
- reset
- Type: Boolean
False to keep the existing setup.
Return Value
[T:FastMoq.Models.MockModel<T>.Mock]
Example of how to set up for mocks that require specific functionality.
C#
mocks.Initialize<ICarService>(mock => {
mock.Setup(x => x.StartCar).Returns(true));
mock.Setup(x => x.StopCar).Returns(false));
}