Language

Assert.ThrowsExceptionAsync Method

Definition

Overloads

Name Description
ThrowsExceptionAsync(Func, 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(Func)

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(Func, 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(Func, String)

Source:
Assert.cs
Source:
Assert.ThrowsException.cs
Source:
Assert.ThrowsException.cs
Source:
Assert.cs
Source:
Assert.cs
Source:
Assert.cs
Source:
Assert.cs
Source:
Assert.cs
Source:
Assert.cs
Source:
Assert.ThrowsException.cs
Source:
Assert.ThrowsException.cs

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 ThrowsExceptionAsync(Func action, string message) where T : Exception;
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public static System.Threading.Tasks.Task ThrowsExceptionAsync(Func action, string message) where T : Exception;
static member ThrowsExceptionAsync : Func * string -> System.Threading.Tasks.Task<'T (requires 'T :> Exception)> (requires 'T :> Exception)
[]
static member ThrowsExceptionAsync : Func * 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

The Task executing the delegate.

Attributes

Exceptions

Thrown if action does not throws exception of type T.

Applies to

ThrowsExceptionAsync(Func)

Source:
Assert.cs
Source:
Assert.ThrowsException.cs
Source:
Assert.ThrowsException.cs
Source:
Assert.cs
Source:
Assert.cs
Source:
Assert.cs
Source:
Assert.cs
Source:
Assert.cs
Source:
Assert.cs
Source:
Assert.ThrowsException.cs
Source:
Assert.ThrowsException.cs

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 ThrowsExceptionAsync(Func action) where T : Exception;
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public static System.Threading.Tasks.Task ThrowsExceptionAsync(Func action) where T : Exception;
static member ThrowsExceptionAsync : Func -> System.Threading.Tasks.Task<'T (requires 'T :> Exception)> (requires 'T :> Exception)
[]
static member ThrowsExceptionAsync : Func -> 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

The Task executing the delegate.

Attributes

Exceptions

Thrown if action does not throws exception of type T.

Applies to

ThrowsExceptionAsync(Func, String, Object[])

Source:
Assert.cs
Source:
Assert.ThrowsException.cs
Source:
Assert.ThrowsException.cs
Source:
Assert.cs
Source:
Assert.cs
Source:
Assert.cs
Source:
Assert.cs
Source:
Assert.cs
Source:
Assert.cs
Source:
Assert.ThrowsException.cs
Source:
Assert.ThrowsException.cs

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 ThrowsExceptionAsync(Func action, string message, params object[] parameters) where T : Exception;
public static System.Threading.Tasks.Task ThrowsExceptionAsync(Func action, string message, params object?[]? parameters) where T : Exception;
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public static System.Threading.Tasks.Task ThrowsExceptionAsync(Func action, string message, params object?[]? parameters) where T : Exception;
static member ThrowsExceptionAsync : Func * string * obj[] -> System.Threading.Tasks.Task<'T (requires 'T :> Exception)> (requires 'T :> Exception)
[]
static member ThrowsExceptionAsync : Func * 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

The Task executing the delegate.

Attributes

Exceptions

Thrown if action does not throws exception of type T.

Applies to