Search Results for

    Show / Hide Table of Contents

    Class ThrowsExceptionConstraint

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

    Inheritance
    object
    Constraint
    ThrowsExceptionConstraint
    Implements
    IConstraint
    IResolveConstraint
    Inherited Members
    Constraint.ApplyTo<TActual>(ref TActual)
    Constraint.GetTestObject<TActual>(ActualValueDelegate<TActual>)
    Constraint.ToString()
    Constraint.GetStringRepresentation(IEnumerable)
    Constraint.GetStringRepresentation()
    Constraint.After(int)
    Constraint.After(int, int)
    Constraint.DisplayName
    Constraint.Arguments
    Constraint.Builder
    Constraint.And
    Constraint.With
    Constraint.Or
    object.GetType()
    object.MemberwiseClone()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    Namespace: NUnit.Framework.Constraints
    Assembly: nunit.framework.dll
    Syntax
    public class ThrowsExceptionConstraint : Constraint, IConstraint, IResolveConstraint

    Constructors

    View Source

    ThrowsExceptionConstraint()

    Declaration
    public ThrowsExceptionConstraint()

    Properties

    View Source

    Description

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

    Declaration
    public override string Description { get; }
    Property Value
    Type Description
    string
    Overrides
    Constraint.Description

    Methods

    View Source

    ApplyToAsync<TActual>(Func<Task<TActual>>)

    Applies the constraint to a delegate that returns the task. The default implementation simply evaluates the delegate and awaits the task but derived classes may override it to provide for delayed processing.

    Declaration
    public override Task<ConstraintResult> ApplyToAsync<TActual>(Func<Task<TActual>> actual)
    Parameters
    Type Name Description
    Func<Task<TActual>> actual
    Returns
    Type Description
    Task<ConstraintResult>
    Type Parameters
    Name Description
    TActual
    Overrides
    Constraint.ApplyToAsync<TActual>(Func<Task<TActual>>)
    View Source

    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.

    Declaration
    public override ConstraintResult ApplyTo<TActual>(ActualValueDelegate<TActual> del)
    Parameters
    Type Name Description
    ActualValueDelegate<TActual> del
    Returns
    Type Description
    ConstraintResult
    Type Parameters
    Name Description
    TActual
    Overrides
    Constraint.ApplyTo<TActual>(ActualValueDelegate<TActual>)
    View Source

    ApplyTo<TActual>(TActual)

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

    Declaration
    public override ConstraintResult ApplyTo<TActual>(TActual actual)
    Parameters
    Type Name Description
    TActual actual

    A delegate representing the code to be tested

    Returns
    Type Description
    ConstraintResult

    True if an exception is thrown, otherwise false

    Type Parameters
    Name Description
    TActual
    Overrides
    Constraint.ApplyTo<TActual>(TActual)

    Implements

    IConstraint
    IResolveConstraint
    • View Source
    In this article
    Back to top Generated by DocFX | Copyright (c) 2018- The NUnit Project - Licensed under CC BY-NC-SA 4.0