Moq |
IReturns<(Of <(TResult>)>)..::.Returns<(Of <(T1, T2, T3, T4>)>) Method (<(Of <(T1, T2, T3, T4, 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, T4>( Func<T1, T2, T3, T4, TResult> valueFunction ) |
Parameters
- valueFunction
- Type: Func<(Of <(T1, T2, T3, T4, 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.
- T4
- Type of the fourth argument of the invoked method.
Examples
Return a calculated value which is evaluated lazily at the time of the invocation.
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.Expect(x => x.Execute( It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>(), It.IsAny<bool>())) .Returns((string arg1, string arg2, int arg3, bool arg4) => arg1 + arg2 + arg3 + arg4);