Table of Contents

Method RaisesAnyAsync

Namespace
Xunit
Assembly
xunit.v3.assert.dll

RaisesAnyAsync(Action<EventHandler>, Action<EventHandler>, Func<Task>)

Verifies that an event is raised.

public static Task<Assert.RaisedEvent<EventArgs>> RaisesAnyAsync(Action<EventHandler> attach, Action<EventHandler> detach, Func<Task> testCode)

Parameters

attach Action<EventHandler>

Code to attach the event handler

detach Action<EventHandler>

Code to detach the event handler

testCode Func<Task>

A delegate to the code to be tested

Returns

Task<Assert.RaisedEvent<EventArgs>>

The event sender and arguments wrapped in an object

Exceptions

Thrown when the expected event was not raised.

RaisesAnyAsync<T>(Action<Action<T>>, Action<Action<T>>, Func<Task>)

Verifies that an event with the exact or a derived event args is raised.

public static Task<Assert.RaisedEvent<T>> RaisesAnyAsync<T>(Action<Action<T>> attach, Action<Action<T>> detach, Func<Task> testCode)

Parameters

attach Action<Action<T>>

Code to attach the event handler

detach Action<Action<T>>

Code to detach the event handler

testCode Func<Task>

A delegate to the code to be tested

Returns

Task<Assert.RaisedEvent<T>>

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.

RaisesAnyAsync<T>(Action<EventHandler<T>>, Action<EventHandler<T>>, Func<Task>)

Verifies that an event with the exact or a derived event args is raised.

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

Parameters

attach Action<EventHandler<T>>

Code to attach the event handler

detach Action<EventHandler<T>>

Code to detach the event handler

testCode Func<Task>

A delegate to the code to be tested

Returns

Task<Assert.RaisedEvent<T>>

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.