Raises Method (Action(T), EventArgs)

Moq

Collapse image Expand Image Copy image CopyHover image
Specifies the event that will be raised when the setup is met.

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

Syntax

C#
IVerifies Raises(
	Action<T> eventExpression,
	EventArgs args
)

Parameters

eventExpression
Type: System..::..Action<(Of <(<'T>)>)>
An expression that represents an event attach or detach action.
args
Type: System..::..EventArgs
The event arguments to pass for the raised event.

Examples

The following example shows how to raise an event when the setup is met:
CopyC#
var mock = new Mock<IContainer>();

mock.Setup(add => add.Add(It.IsAny<string>(), It.IsAny<object>()))
    .Raises(add => add.Added += null, EventArgs.Empty);

See Also