Assert.ThrowsException<T> 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.
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
.