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