Delen via


Assert.ThrowsException<T> Method

Definition

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 T ThrowsException(Func<System::Object ^> ^ action);
public static T ThrowsException<T> (Func<object> action) where T : Exception;
static member ThrowsException : Func<obj> -> 'T (requires 'T :> Exception)
Public Shared Function ThrowsException(Of T As Exception) (action As Func(Of Object)) As T

Type Parameters

T

Type of exception expected to be thrown.

Exceptions

Thrown if action does not throws exception of type T.

Applies to