Callback Method ()

Moq 2.6

Specifies a callback to invoke when the method is called.

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

Syntax

C#
ICallbackResult Callback(
	Action callback
)

Parameters

callback
Type: Action
Callback method to invoke.

Examples

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

See Also