[This is preliminary documentation and is subject to change.]
Specifies a function that will calculate the value to return from the method.
Namespace:
MoqAssembly: Moq (in Moq)
Version: 1.5.2951.38938 (1.5.0.0)
Syntax
| C# |
|---|
void Returns( Func<TResult> valueFunction ) |
Parameters
- valueFunction
- Type: System..::.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]);