Assert.

Throws(IResolveConstraint, TestDelegate, string, object[]) Method

Summary

Asserts that a delegate throws an exception, which satisfies a provided Constraint. If no exception is thrown or if the constraint is not satisfied, then a TCLite.AssertionException is thrown, ending the test and reporting it as a Failure.
Namespace
TCLite
Containing Type
Assert

Syntax

public static Exception Throws(IResolveConstraint expression, TestDelegate code, string message = null, params object[] args)

Remarks

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

Parameters

Name Type Description
expression IResolveConstraint A constraint to be satisfied by the exception
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
Exception The exception that was thrown