Table of Contents

Class ThrowsExceptionConstraint

Namespace
NUnit.Framework.Constraints
Assembly
nunit.framework.dll

ThrowsExceptionConstraint tests that an exception has been thrown, without any further tests.

public class ThrowsExceptionConstraint : Constraint, IConstraint, IResolveConstraint
Inheritance
ThrowsExceptionConstraint
Implements
Inherited Members

Constructors

ThrowsExceptionConstraint()

public ThrowsExceptionConstraint()

Properties

Description

The Description of what this constraint tests, for use in messages and in the ConstraintResult.

public override string Description { get; }

Property Value

string

Methods

ApplyTo<TActual>(ActualValueDelegate<TActual>)

Applies the constraint to an ActualValueDelegate that returns the value to be tested. The default implementation simply evaluates the delegate but derived classes may override it to provide for delayed processing.

public override ConstraintResult ApplyTo<TActual>(ActualValueDelegate<TActual> del)

Parameters

del ActualValueDelegate<TActual>

Returns

ConstraintResult

Type Parameters

TActual

ApplyTo<TActual>(TActual)

Executes the code and returns success if an exception is thrown.

public override ConstraintResult ApplyTo<TActual>(TActual actual)

Parameters

actual TActual

A delegate representing the code to be tested

Returns

ConstraintResult

True if an exception is thrown, otherwise false

Type Parameters

TActual