Expect(TResult) Method (((T, TResult)))

Moq 2.6

Sets an expectation on the mocked type for a call to to a value returning method.

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

Syntax

C#
IExpect<TResult> Expect<TResult>(
	Expression<Func<T, TResult>> expression
)

Parameters

expression
Type: Expression<(Of <(Func<(Of <(T, TResult>)>)>)>)
Lambda expression that specifies the expected 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 expectation is set for the same method or property, the latest one wins and is the one that will be executed.

Examples

CopyC#
mock.Expect(x => x.HasInventory("Talisker", 50)).Returns(true);

See Also