Setup Method (Expression(Action(T)))

Moq

Collapse image Expand Image Copy image CopyHover image
Specifies a setup on the mocked type for a call to to a void method.

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

Syntax

C#
public ISetup<T> Setup(
	Expression<Action<T>> expression
)

Parameters

expression
Type: System.Linq.Expressions..::..Expression<(Of <(<'Action<(Of <(<'T>)>)>>)>)>
Lambda expression that specifies the expected method invocation.

Remarks

If more than one setup is specified for the same method or property, the latest one wins and is the one that will be executed.

Examples

CopyC#
var mock = new Mock<IProcessor>();
mock.Setup(x => x.Execute("ping"));

See Also