Summary
The Constraint class is the base of all built-in constraints
within TCLite. The class models a constraint, which puts no
limitations on the type of actual value it is able to handle.
- Namespace
- TCLite
.Constraints - Interfaces
- Base Types
-
- object
- Derived Types
graph BT
Type-->Base0["object"]
Type-.->Interface0["IConstraint"]
click Interface0 "/tc-lite/api/TCLite.Constraints/IConstraint"
Type-.->Interface1["IResolveConstraint"]
click Interface1 "/tc-lite/api/TCLite.Constraints/IResolveConstraint"
Type["Constraint"]
class Type type-node
Derived0["ExactCountConstraint"]-->Type
click Derived0 "/tc-lite/api/TCLite.Constraints/ExactCountConstraint"
Derived1["ThrowsNothingConstraint"]-->Type
click Derived1 "/tc-lite/api/TCLite.Constraints/ThrowsNothingConstraint"
Derived2["NullConstraint"]-->Type
click Derived2 "/tc-lite/api/TCLite.Constraints/NullConstraint"
Derived3["PrefixConstraint"]-->Type
click Derived3 "/tc-lite/api/TCLite.Constraints/PrefixConstraint"
Derived4["ExpectedValueConstraint<TExpected>"]-->Type
click Derived4 "/tc-lite/api/TCLite.Constraints/ExpectedValueConstraint_1"
Derived5["PropertyExistsConstraint"]-->Type
click Derived5 "/tc-lite/api/TCLite.Constraints/PropertyExistsConstraint"
Derived6["ThrowsExceptionConstraint"]-->Type
click Derived6 "/tc-lite/api/TCLite.Constraints/ThrowsExceptionConstraint"
Derived7["EmptyConstraint"]-->Type
click Derived7 "/tc-lite/api/TCLite.Constraints/EmptyConstraint"
Derived8["BinaryConstraint"]-->Type
click Derived8 "/tc-lite/api/TCLite.Constraints/BinaryConstraint"
Derived9["RangeConstraint<TExpected>"]-->Type
click Derived9 "/tc-lite/api/TCLite.Constraints/RangeConstraint_1"
Derived10["ConditionConstraint<TActual>"]-->Type
click Derived10 "/tc-lite/api/TCLite.Constraints/ConditionConstraint_1"
Derived11["RegexConstraint"]-->Type
click Derived11 "/tc-lite/api/TCLite.Constraints/RegexConstraint"
Syntax
public abstract class Constraint : IConstraint, IResolveConstraint
Remarks
This file contains Modifers that apply to all constraints as
well as the two Binary Operators.
Constructors
Name | Summary |
---|---|
Constraint |
Construct a constraint with optional arguments |
Properties
Name | Value | Summary |
---|---|---|
And | ConstraintExpression |
Returns a ConstraintExpression by appending And
to the current constraint.
|
Arguments | object[] |
Arguments provided to this Constraint, for use in
formatting the description.
|
Builder | ConstraintBuilder |
A ConstraintBuilder holding this constraint. If not null
the constraint is under construction.
|
Description | string |
The Description of what this constraint tests, for
use in messages and in the ConstraintResult.
|
DisplayName | string |
The display name of this Constraint for use by ToString().
The default value is the name of the constraint with
trailing "Constraint" removed. Derived classes may set
this to another name in their constructors.
|
Or | ConstraintExpression |
Returns a ConstraintExpression by appending Or
to the current constraint.
|
With | ConstraintExpression |
Returns a ConstraintExpression by appending And
to the current constraint.
|
Methods
Name | Value | Summary |
---|---|---|
ApplyConstraint |
ConstraintResult |
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.
|
ApplyConstraint |
ConstraintResult |
Applies the constraint to the value to be tested and returns
a ConstraintResult.
|
ApplyConstraint |
ConstraintResult |
Test whether the constraint is satisfied by a given reference.
The default implementation simply dereferences the value but
derived classes may override it to provide for delayed processing.
|
ApplyTo |
ConstraintResult |
Validates the ActualValueDelegate and applies the constraint
to the value it returns.
|
ApplyTo |
ConstraintResult |
Validates the actual value argument and applies the constraint
to it, returning a ConstraintResult.
|
ApplyTo |
ConstraintResult |
Validates the actual value argument and applies the constraint
to it, returning a ConstraintResult.
|
Get |
string |
Returns the string representation of this constraint
|
ToString |
string |
Default override of ToString returns the constraint DisplayName
followed by any arguments within angle brackets.
|
ValidateActualValue |
void |
Validate the actual value argument based on what the
particular constraint allows. The default
implementation does nothing, implying that the constraint
can handle any Type as well as null values.
|