Moq |
IReturns<(Of <(<'TMock, TResult>)>)>..::..Returns<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>)>)> Method (Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult>)>)>) |
IReturns<(Of <(<'TMock, 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: 4.0.10827.0 (4.0.0.0)
Syntax
C# |
---|
IReturnsResult<TMock> Returns<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>( Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult> valueFunction ) |
Parameters
- valueFunction
- Type: System..::..Func<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult>)>)>
The function that will calculate the return value.
Type Parameters
- T1
- The type of the first argument of the invoked method.
- T2
- The type of the second argument of the invoked method.
- T3
- The type of the third argument of the invoked method.
- T4
- The type of the fourth argument of the invoked method.
- T5
- The type of the fifth argument of the invoked method.
- T6
- The type of the sixth argument of the invoked method.
- T7
- The type of the seventh argument of the invoked method.
- T8
- The type of the eighth argument of the invoked method.
- T9
- The type of the nineth argument of the invoked method.
- T10
- The type of the tenth argument of the invoked method.
- T11
- The type of the eleventh argument of the invoked method.
- T12
- The type of the twelfth argument of the invoked method.
Examples
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:
CopyC#
mock.Setup(x => x.Execute( It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>())) .Returns((string arg1, string arg2, string arg3, string arg4, string arg5, string arg6, string arg7, string arg8, string arg9, string arg10, string arg11, string arg12) => arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12);