Callback Method (Action)

Moq

Collapse image Expand Image Copy image CopyHover image
Specifies a callback to invoke when the method is called.

Namespace: Moq.Language
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
ICallbackResult Callback(
	Action action
)

Parameters

action
Type: System..::..Action
The callback method to invoke.

Examples

The following example specifies a callback to set a boolean value that can be used later:
CopyC#
var called = false;
mock.Setup(x => x.Execute())
    .Callback(() => called = true);

See Also