Assert.ThrowsExceptionAsync Method

Definition

Overloads

ThrowsExceptionAsync<T>(Func<Task>, String)

Tests whether the code specified by delegate action throws exact given exception of type T (and not of derived type) and throws

AssertFailedException
if code does not throws exception or throws exception of type other than T.

ThrowsExceptionAsync<T>(Func<Task>)

Tests whether the code specified by delegate action throws exact given exception of type T (and not of derived type) and throws


AssertFailedException

if code does not throws exception or throws exception of type other than T.

ThrowsExceptionAsync<T>(Func<Task>, String, Object[])

Tests whether the code specified by delegate action throws exact given exception of type T (and not of derived type) and throws

AssertFailedException
if code does not throws exception or throws exception of type other than T.

ThrowsExceptionAsync<T>(Func<Task>, String)

Tests whether the code specified by delegate action throws exact given exception of type T (and not of derived type) and throws

AssertFailedException
if code does not throws exception or throws exception of type other than T.

public static System.Threading.Tasks.Task<T> ThrowsExceptionAsync<T> (Func<System.Threading.Tasks.Task> action, string message) where T : Exception;
static member ThrowsExceptionAsync : Func<System.Threading.Tasks.Task> * string -> System.Threading.Tasks.Task<'T (requires 'T :> Exception)> (requires 'T :> Exception)
Public Shared Function ThrowsExceptionAsync(Of T As Exception) (action As Func(Of Task), message As String) As Task(Of T)

Type Parameters

T

Type of exception expected to be thrown.

Parameters

action
Func<Task>

Delegate to code to be tested and which is expected to throw exception.

message
String

The message to include in the exception when action does not throws exception of type T.

Returns

Task<T>

The Task executing the delegate.

Exceptions

Thrown if action does not throws exception of type T.

ThrowsExceptionAsync<T>(Func<Task>)

Tests whether the code specified by delegate action throws exact given exception of type T (and not of derived type) and throws


AssertFailedException

if code does not throws exception or throws exception of type other than T.

public static System.Threading.Tasks.Task<T> ThrowsExceptionAsync<T> (Func<System.Threading.Tasks.Task> action) where T : Exception;
static member ThrowsExceptionAsync : Func<System.Threading.Tasks.Task> -> System.Threading.Tasks.Task<'T (requires 'T :> Exception)> (requires 'T :> Exception)
Public Shared Function ThrowsExceptionAsync(Of T As Exception) (action As Func(Of Task)) As Task(Of T)

Type Parameters

T

Type of exception expected to be thrown.

Parameters

action
Func<Task>

Delegate to code to be tested and which is expected to throw exception.

Returns

Task<T>

The Task executing the delegate.

Exceptions

Thrown if action does not throws exception of type T.

ThrowsExceptionAsync<T>(Func<Task>, String, Object[])

Tests whether the code specified by delegate action throws exact given exception of type T (and not of derived type) and throws

AssertFailedException
if code does not throws exception or throws exception of type other than T.

public static System.Threading.Tasks.Task<T> ThrowsExceptionAsync<T> (Func<System.Threading.Tasks.Task> action, string message, params object[] parameters) where T : Exception;
static member ThrowsExceptionAsync : Func<System.Threading.Tasks.Task> * string * obj[] -> System.Threading.Tasks.Task<'T (requires 'T :> Exception)> (requires 'T :> Exception)
Public Shared Function ThrowsExceptionAsync(Of T As Exception) (action As Func(Of Task), message As String, ParamArray parameters As Object()) As Task(Of T)

Type Parameters

T

Type of exception expected to be thrown.

Parameters

action
Func<Task>

Delegate to code to be tested and which is expected to throw exception.

message
String

The message to include in the exception when action does not throws exception of type T.

parameters
Object[]

An array of parameters to use when formatting message.

Returns

Task<T>

The Task executing the delegate.

Exceptions

Thrown if action does not throws exception of type T.

Applies to