Table of Contents

Class TypeConstraint

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

TypeConstraint is the abstract base for constraints that take a Type as their expected value.

public abstract class TypeConstraint : Constraint, IConstraint, IResolveConstraint
Inheritance
TypeConstraint
Implements
Derived
Inherited Members

Constructors

TypeConstraint(Type, string)

Construct a TypeConstraint for a given Type

protected TypeConstraint(Type type, string descriptionPrefix)

Parameters

type Type

The expected type for the constraint

descriptionPrefix string

Prefix used in forming the constraint description

Fields

actualType

The type of the actual argument to which the constraint was applied

protected Type actualType

Field Value

Type

expectedType

The expected Type used by the constraint

protected Type expectedType

Field Value

Type

Methods

ApplyTo<TActual>(TActual)

Applies the constraint to an actual value, returning a ConstraintResult.

public override ConstraintResult ApplyTo<TActual>(TActual actual)

Parameters

actual TActual

The value to be tested

Returns

ConstraintResult

A ConstraintResult

Type Parameters

TActual

Matches(object)

Apply the constraint to an actual value, returning true if it succeeds

protected abstract bool Matches(object actual)

Parameters

actual object

The actual argument

Returns

bool

True if the constraint succeeds, otherwise false.