Assert.ThrowsExceptionAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
ThrowsExceptionAsync<T>(Func<Task>) |
Tests whether the code specified by delegate |
ThrowsExceptionAsync<T>() |
Tests whether the code specified by delegate |
ThrowsExceptionAsync<T>(Func<Task>, String, Object[]) |
Tests whether the code specified by delegate |
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:
generic <typename T>
where T : Exception static System::Threading::Tasks::Task<T> ^ ThrowsExceptionAsync(Func<System::Threading::Tasks::Task ^> ^ action);
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
Exceptions
Thrown if action
does not throws exception of type T
.
Applies to
ThrowsExceptionAsync<T>()
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:
generic <typename T>
where T : Exception static System::Threading::Tasks::Task<T> ^ ThrowsExceptionAsync(Func<System::Threading::Tasks::Task ^> ^ action, System::String ^ message);
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.
Exceptions
Thrown if action
does not throws exception of type T
.
Applies to
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:
generic <typename T>
where T : Exception static System::Threading::Tasks::Task<T> ^ ThrowsExceptionAsync(Func<System::Threading::Tasks::Task ^> ^ action, System::String ^ message, ... cli::array <System::Object ^> ^ parameters);
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
- 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
.
Exceptions
Thrown if action
does not throws exception of type T
.