Callback(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) Method (Action(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11))

Moq

Collapse image Expand Image Copy image CopyHover image
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, T10, T11>(
	Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> action
)

Parameters

action
Type: System..::..Action<(Of <(<'T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>)>)>
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.
T10
The type of the tenth argument of the invoked method.
T11
The type of the eleventh argument of the invoked method.

Return Value

A reference to IReturnsThrows interface.

Examples

Invokes the given callback with the concrete invocation arguments values.

Notice how the specific arguments are retrieved by simply declaring them as part of the lambda expression for the callback:

CopyC#
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>(),
                     It.IsAny<string>(),
                     It.IsAny<string>()))
    .Callback((arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11) => Console.WriteLine(arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11));

See Also