Create(T) Method

Moq

Collapse image Expand Image Copy image CopyHover image
Creates a new mock with the default MockBehavior specified at factory construction time.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

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

Type Parameters

T
Type to mock.

Return Value

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

Examples

CopyC#
var factory = new MockFactory(MockBehavior.Strict);

var foo = factory.Create<IFoo>();
// use mock on tests

factory.VerifyAll();

See Also