







![]() |
Moq |
ICallback<(Of <(<'TMock, TResult>)>)>..::..Callback<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9>)>)> Method (Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9>)>)>) |
ICallback<(Of <(<'TMock, TResult>)>)> Interface Example See Also Send Feedback |
Specifies a callback to invoke when the method is called that receives the original
arguments.
Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)
Syntax
C# |
---|
IReturnsThrows<TMock, TResult> Callback<T1, T2, T3, T4, T5, T6, T7, T8, T9>( Action<T1, T2, T3, T4, T5, T6, T7, T8, T9> action ) |
Parameters
- action
- Type: System..::..Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9>)>)>
The callback method to invoke.
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.
Return Value
A reference to IReturnsThrows interface.
Examples
Invokes the given callback with the concrete invocation arguments values.
CopyC#
Notice how the specific arguments are retrieved by simply declaring them as part of the lambda expression for the callback:

mock.Setup(x => x.Execute( It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())) .Callback((arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9));