Method RaisesAsync
- Namespace
- Xunit
- Assembly
- xunit.v3.assert.dll
RaisesAsync(Action<Action>, Action<Action>, Func<Task>)
Verifies that an event is raised.
public static Task RaisesAsync(Action<Action> attach, Action<Action> detach, Func<Task> testCode)
Parameters
attachAction<Action>Code to attach the event handler
detachAction<Action>Code to detach the event handler
testCodeFunc<Task>A delegate to the code to be tested
Returns
- Task
The event sender and arguments wrapped in an object
Exceptions
Thrown when the expected event was not raised.
RaisesAsync<T>(Action<Action<T>>, Action<Action<T>>, Func<Task>)
Verifies that an event with the exact event args (and not a derived type) is raised.
public static Task<Assert.RaisedEvent<T>> RaisesAsync<T>(Action<Action<T>> attach, Action<Action<T>> detach, Func<Task> testCode)
Parameters
attachAction<Action<T>>Code to attach the event handler
detachAction<Action<T>>Code to detach the event handler
testCodeFunc<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
TThe type of the event arguments to expect
Exceptions
Thrown when the expected event was not raised.
RaisesAsync<T>(Action<EventHandler<T>>, Action<EventHandler<T>>, Func<Task>)
Verifies that an event with the exact event args (and not a derived type) is raised.
public static Task<Assert.RaisedEvent<T>> RaisesAsync<T>(Action<EventHandler<T>> attach, Action<EventHandler<T>> detach, Func<Task> testCode)
Parameters
attachAction<EventHandler<T>>Code to attach the event handler
detachAction<EventHandler<T>>Code to detach the event handler
testCodeFunc<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
TThe type of the event arguments to expect
Exceptions
Thrown when the expected event was not raised.