Raise Method (Action(T), Object[])

Moq

Collapse image Expand Image Copy image CopyHover image
Raises the event referenced in eventExpression using the given args argument for a non-EventHandler typed event.

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

Syntax

C#
public void Raise(
	Action<T> eventExpression,
	params Object[] args
)

Parameters

eventExpression
Type: System..::..Action<(Of <(<'T>)>)>
args
Type: array<System..::..Object>[]()[][]

Examples

The following example shows how to raise a custom event that does not adhere to the standard EventHandler:
CopyC#
var mock = new Mock<IViewModel>();

mock.Raise(x => x.MyEvent -= null, "Name", bool, 25);

Exceptions

Exception Condition
System..::..ArgumentException The args arguments are invalid for the target event invocation, or the eventExpression is not an event attach or detach expression.

See Also