







![]() |
Moq |
ICallback<(Of <(<'TMock, TResult>)>)>..::..Callback<(Of <(<'T>)>)> Method (Action<(Of <(<'T>)>)>) |
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<T>( Action<T> action ) |
Parameters
- action
- Type: System..::..Action<(Of <(<'T>)>)>
Callback method to invoke.
Type Parameters
- T
- The type of the argument of the invoked method.
Examples
Invokes the given callback with the concrete invocation argument value.
CopyC#
Notice how the specific string argument is retrieved by simply declaring it as part of the lambda expression for the callback:

mock.Setup(x => x.Execute(It.IsAny<string>())) .Callback(command => Console.WriteLine(command)) .Returns(true);