Raises the event referenced in eventExpression using
the given sender and args arguments
for a non-EventHandler typed event.
Namespace:
MoqAssembly: Moq (in Moq.dll) Version: 4.0.812.4 (4.0.0.0)
Syntax
| C# |
|---|
public void Raise( Action<T> eventExpression, params Object[] args ) |
Parameters
- eventExpression
- Type: Action<(Of <(T>)>)
[Missing <param name="eventExpression"/> documentation for "M:Moq.Mock`1.Raise(System.Action{`0},System.Object[])"]
- args
- Type: array<
Object
>[]()[]
[Missing <param name="args"/> documentation for "M:Moq.Mock`1.Raise(System.Action{`0},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 |
|---|---|
| ArgumentException | The args arguments are invalid for the target event invocation, or the eventExpression is not an event attach or detach expression. |