Class ThrowsConstraint
- Namespace
- NUnit.Framework.Constraints
- Assembly
- nunit.framework.dll
ThrowsConstraint is used to test the exception thrown by a delegate by applying a constraint to it.
public class ThrowsConstraint : PrefixConstraint, IConstraint, IResolveConstraint
- Inheritance
-
ThrowsConstraint
- Implements
- Inherited Members
Constructors
ThrowsConstraint(IConstraint)
Initializes a new instance of the ThrowsConstraint class, using a constraint to be applied to the exception.
public ThrowsConstraint(IConstraint baseConstraint)
Parameters
baseConstraint
IConstraintA constraint to apply to the caught exception.
Properties
ActualException
Get the actual exception thrown - used by Assert.Throws.
public Exception ActualException { get; }
Property Value
Description
Gets text describing a constraint
public override string Description { get; }
Property Value
Methods
ApplyTo<TActual>(ActualValueDelegate<TActual>)
Converts an ActualValueDelegate to a TestDelegate before calling the primary overload.
public override ConstraintResult ApplyTo<TActual>(ActualValueDelegate<TActual> del)
Parameters
del
ActualValueDelegate<TActual>
Returns
Type Parameters
TActual
ApplyTo<TActual>(TActual)
Executes the code of the delegate and captures any exception. If a non-null base constraint was provided, it applies that constraint to the exception.
public override ConstraintResult ApplyTo<TActual>(TActual actual)
Parameters
actual
TActualA delegate representing the code to be tested
Returns
- ConstraintResult
True if an exception is thrown and the constraint succeeds, otherwise false
Type Parameters
TActual