ConstraintExpression Class

Summary

ConstraintExpression represents a compound constraint in the process of being constructed from a series of syntactic elements. Individual elements are appended to the expression as they are recognized. Once an actual Constraint is appended, the expression returns a resolvable Constraint.
graph BT Type-->Base0["object"] Type["ConstraintExpression"] class Type type-node Derived0["ResolvableConstraintExpression"]-->Type click Derived0 "/tc-lite/api/TCLite.Constraints/ResolvableConstraintExpression" Derived1["ItemsConstraintExpression"]-->Type click Derived1 "/tc-lite/api/TCLite.Constraints/ItemsConstraintExpression"

Syntax

public class ConstraintExpression

Remarks

This is a partial class, with the individual syntactic elements like "Not", "All" or "EqualTo" distributed in individual files for the constraint or operator they generate. For example, "Not" is defined in NotOperator.cs and "EqualTo" in EqualConstraint.cs.

Constructors

Name Summary
ConstraintExpression() Initializes a new instance of the ConstraintExpression class.
ConstraintExpression(ConstraintBuilder) Initializes a new instance of the ConstraintExpression class passing in a ConstraintBuilder, which may be pre-populated.

Properties

Name Value Summary
Builder ConstraintBuilder
The ConstraintBuilder associated with this expression
False FalseConstraint
Returns a constraint that tests for False
Negative LessThanConstraint<int>
Returns a constraint that tests for a negative value
Null NullConstraint
Returns a constraint that tests for null
One ItemsConstraintExpression
Returns a ItemsConstraintExpression which will apply the following constraint to only one member of the collection, and fail if none or more than one match occurs.
Positive GreaterThanConstraint<int>
Returns a constraint that tests for a positive value
True TrueConstraint
Returns a constraint that tests for True
Unique UniqueItemsConstraint
Returns a constraint that tests whether a collection contains all unique items.
Zero EqualConstraint<int>
Returns a constraint that tests if item is equal to zero

Methods

Name Value Summary
Append(Constraint) Constraint
Appends a constraint to the expression and returns that constraint, which is associated with the current state of the expression being built.
Append(ConstraintOperator) ConstraintExpression
Appends an operator to the expression and returns the resulting expression itself.
Append(SelfResolvingOperator) ResolvableConstraintExpression
Appends a self-resolving operator to the expression and returns a new ResolvableConstraintExpression.
AtLeast<T>(T) GreaterThanOrEqualConstraint<T>
Returns a constraint that tests whether the actual value is greater than or equal to the suppled argument
AtMost<T>(T) LessThanOrEqualConstraint<T>
Returns a constraint that tests whether the actual value is less than or equal to the suppled argument
Contains(string) ContainsConstraint<string>
Returns a new ContainsConstraint. This constraint will, in turn, make use of the appropriate second-level constraint, depending on the type of the actual argument. This overload is only used if the item sought is a string, since any other type implies that we are looking for a collection member.
ContainsSubstring(string) SubstringConstraint
Returns a constraint that succeeds if the actual value contains the substring supplied as an argument.
EndsWith(string) EndsWithConstraint
Returns a constraint that succeeds if the actual value ends with the substring supplied as an argument.
EqualTo<T>(T) EqualConstraint<T>
Returns a constraint that tests two items for equality
EquivalentTo(IEnumerable) CollectionEquivalentConstraint
Returns a constraint that tests whether the actual value is a collection containing the same elements as the collection supplied as an argument.
Exactly(int) ItemsConstraintExpression
Returns a ConstraintExpression, which will apply the following constraint to all members of a collection, succeeding only if a specified number of them succeed.
GreaterThan<T>(T) GreaterThanConstraint<T>
Returns a constraint that tests whether the actual value is greater than the suppled argument
GreaterThanOrEqualTo<T>(T) GreaterThanOrEqualConstraint<T>
Returns a constraint that tests whether the actual value is greater than or equal to the suppled argument
InRange<T>(T, T) RangeConstraint<T>
Returns a constraint that tests whether the actual value falls within a specified range.
InstanceOf(Type) InstanceOfTypeConstraint
Returns a constraint that tests whether the actual value is of the type supplied as an argument or a derived type.
InstanceOf<T>() InstanceOfTypeConstraint
Returns a constraint that tests whether the actual value is of the type supplied as an argument or a derived type.
LessThan<T>(T) LessThanConstraint<T>
Returns a constraint that tests whether the actual value is less than the suppled argument
LessThanOrEqualTo<T>(T) LessThanOrEqualConstraint<T>
Returns a constraint that tests whether the actual value is less than or equal to the suppled argument
Matches(Regex) RegexConstraint
Returns a constraint that succeeds if the actual value matches the regular expression supplied as an argument.
Matches(string, RegexOptions) RegexConstraint
Returns a constraint that succeeds if the actual value matches the regular expression supplied as an argument.
SameAs<T>(T) SameAsConstraint<T>
Returns a constraint that tests that two references are the same object
StartsWith(string) StartsWithConstraint
Returns a constraint that succeeds if the actual value starts with the substring supplied as an argument.
TypeOf(Type) ExactTypeConstraint
Returns a constraint that tests whether the actual value is of the exact type supplied as an argument.
TypeOf<T>() ExactTypeConstraint
Returns a constraint that tests whether the actual value is of the exact type supplied as an argument.