Mock(T) Constructor (MockBehavior, [])

Moq 2.6

Initializes an instance of the mock with a specific behavior with the given constructor arguments for the class.

Namespace:  Moq
Assembly:  Moq (in Moq.dll) Version: 2.6.1014.1 (2.6.0.0)

Syntax

C#
public Mock(
	MockBehavior behavior,
	params Object[] args
)

Parameters

behavior
Type: Moq..::.MockBehavior
Behavior of the mock.
args
Type: array< Object >[]()[]
Optional constructor arguments if the mocked type is a class.

Remarks

The mock will try to find the best match constructor given the constructor arguments, and invoke that to initialize the instance. This applies only to classes, not interfaces.

Examples

CopyC#
var mock = new Mock<MyProvider>(someArgument, 25);

See Also