







![]() |
Moq |
IReturns<(Of <(TResult>)>)..::.Returns<(Of <(T1, T2, T3>)>) Method (<(Of <(T1, T2, T3, TResult>)>)) |
IReturns<(Of <(TResult>)>) Interface Example See Also Send Feedback |
Specifies a function that will calculate the value to return from the method,
retrieving the arguments for the invocation.
Namespace:
Moq.Language
Assembly:
Moq (in Moq.dll) Version: 2.6.1014.1 (2.6.0.0)
Syntax
C# |
---|
IReturnsResult Returns<T1, T2, T3>( Func<T1, T2, T3, TResult> valueFunction ) |
Parameters
- valueFunction
- Type: Func<(Of <(T1, T2, T3, TResult>)>)
The function that will calculate the return value.
Type Parameters
- T1
- Type of the first argument of the invoked method.
- T2
- Type of the second argument of the invoked method.
- T3
- Type of the third argument of the invoked method.
Examples
Return a calculated value which is evaluated lazily at the time of the invocation.
CopyC#
The return value is calculated from the value of the actual method invocation arguments. Notice how the arguments are retrieved by simply declaring them as part of the lambda expression:

mock.Expect(x => x.Execute( It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>())) .Returns((string arg1, string arg2, int arg3) => arg1 + arg2 + arg3);