Assert.

Throws<T>(TestDelegate, string, object[]) Method

Summary

Asserts that a delegate throws an exception of the Type specified. If no exception is thrown or if it is of the wrong Type, a TCLite.AssertionException is thrown, ending the test and reporting it as a Failure.
Namespace
TCLite
Containing Type
Assert

Syntax

public static T Throws<T>(TestDelegate code, string message = null, params object[] args) 
    where T : Exception

Remarks

On success, this assertion returns the exception that was thrown. This allows making further assertions on the properties of the exception.

Type Parameters

Name Description
T Type of the expected exception

Parameters

Name Type Description
code TestDelegate A TestDelegate
message string The message that will be displayed on failure
args object[] Arguments to be used in formatting the message

Return Value

Type Description
T The exception that was thrown