







![]() |
Moq |
IReturns<(Of <(TResult>)>)..::.Returns Method (<(Of <(TResult>)>)) |
IReturns<(Of <(TResult>)>) Interface Example See Also Send Feedback |
Specifies a function that will calculate the value to return from the method.
Namespace:
Moq.Language
Assembly:
Moq (in Moq.dll) Version: 2.6.1014.1 (2.6.0.0)
Syntax
C# |
---|
IReturnsResult Returns( Func<TResult> valueFunction ) |
Parameters
- valueFunction
- Type: Func<(Of <(TResult>)>)
The function that will calculate the return value.
Examples
Return a calculated value when the method is called:
CopyC#
The lambda expression to retrieve the return value is lazy-executed,
meaning that its value may change depending on the moment the method
is executed and the value the returnValues array has at
that moment.

mock.Expect(x => x.Execute("ping")) .Returns(() => returnValues[0]);