Table of Contents

Method Raises

Namespace
Xunit
Assembly
xunit.v3.assert.dll

Raises(Action<Action>, Action<Action>, Action)

Verifies that an event is raised.

public static void Raises(Action<Action> attach, Action<Action> detach, Action testCode)

Parameters

attach Action<Action>

Code to attach the event handler

detach Action<Action>

Code to detach the event handler

testCode Action

A delegate to the code to be tested

Exceptions

Thrown when the expected event was not raised.

Raises<T>(Action<Action<T>>, Action<Action<T>>, Action)

Verifies that an event with the exact event args is raised.

public static Assert.RaisedEvent<T> Raises<T>(Action<Action<T>> attach, Action<Action<T>> detach, Action testCode)

Parameters

attach Action<Action<T>>

Code to attach the event handler

detach Action<Action<T>>

Code to detach the event handler

testCode Action

A delegate to the code to be tested

Returns

The event sender and arguments wrapped in an object

Type Parameters

T

The type of the event arguments to expect

Exceptions

Thrown when the expected event was not raised.

Raises<T>(Action<EventHandler<T>>, Action<EventHandler<T>>, Action)

Verifies that an event with the exact event args is raised.

public static Assert.RaisedEvent<T> Raises<T>(Action<EventHandler<T>> attach, Action<EventHandler<T>> detach, Action testCode)

Parameters

attach Action<EventHandler<T>>

Code to attach the event handler

detach Action<EventHandler<T>>

Code to detach the event handler

testCode Action

A delegate to the code to be tested

Returns

The event sender and arguments wrapped in an object

Type Parameters

T

The type of the event arguments to expect

Exceptions

Thrown when the expected event was not raised.

Raises<T>(Func<RaisedEvent<T>?>, Action, Action, Action)

Verifies that an event with the exact event args is raised.

public static Assert.RaisedEvent<T> Raises<T>(Func<Assert.RaisedEvent<T>?> handler, Action attach, Action detach, Action testCode)

Parameters

handler Func<Assert.RaisedEvent<T>>

Code returning the raised event

attach Action

Code to attach the event handler

detach Action

Code to detach the event handler

testCode Action

A delegate to the code to be tested

Returns

The event sender and arguments wrapped in an object

Type Parameters

T

The type of the event arguments to expect

Exceptions

Thrown when the expected event was not raised.