Specifies a setup on the mocked type for a call to to a value returning method.

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

Syntax

C#
public ISetup<T, TResult> Setup<TResult>(
	Expression<Func<T, TResult>> expression
)

Parameters

expression
Type: Expression<(Of <(Func<(Of <(T, TResult>)>)>)>)
Lambda expression that specifies the method invocation.

Type Parameters

TResult
Type of the return value. Typically omitted as it can be inferred from the expression.

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#
mock.Setup(x => x.HasInventory("Talisker", 50)).Returns(true);

See Also