Create(T) Method (MockBehavior)

Moq 2.6

Creates a new mock with the given behavior.

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

Syntax

C#
public Mock<T> Create<T>(
	MockBehavior behavior
)
where T : class

Parameters

behavior
Type: Moq..::.MockBehavior
Behavior to use for the mock, which overrides the default behavior specified at factory construction time.

Type Parameters

T
Type to mock.

Return Value

A new Mock<(Of <(T>)>).

Examples

The following example shows how to create a mock with a different behavior to that specified as the default for the factory:
CopyC#
var factory = new MockFactory(MockBehavior.Strict);

var foo = factory.Create<IFoo>(MockBehavior.Loose);

See Also