Callback(T1, T2, T3) Method ((T1, T2, T3))

Moq 2.6

Specifies a callback to invoke when the method is called that receives the original arguments.

Namespace:  Moq.Language
Assembly:  Moq (in Moq.dll) Version: 2.6.1014.1 (2.6.0.0)

Syntax

C#
ICallbackResult Callback<T1, T2, T3>(
	Action<T1, T2, T3> callback
)

Parameters

callback
Type: Action<(Of <(T1, T2, T3>)>)
Callback method to invoke.

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

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.Expect(x => x.Execute(
                     It.IsAny<string>(), 
                     It.IsAny<string>(), 
                     It.IsAny<int>()))
    .Callback((string arg1, string arg2, int arg3) => Console.WriteLine(arg1 + arg2 + arg3));

See Also