ConstraintFactory Class

Definition

Helper class with properties and methods that supply a number of constraints used in Asserts.

public class ConstraintFactory
type ConstraintFactory = class
Inheritance
ConstraintFactory
Derived

Constructors

ConstraintFactory()

Properties

All

Returns a ConstraintExpression, which will apply the following constraint to all members of a collection, succeeding if all of them succeed.

BinarySerializable

Returns a constraint that tests whether an object graph is serializable in binary format.

Count

Returns a new ConstraintExpression, which will apply the following constraint to the Count property of the object being tested.

Empty

Returns a constraint that tests for empty

False

Returns a constraint that tests for False

InnerException

Returns a new ConstraintExpression, which will apply the following constraint to the InnerException property of the object being tested.

Length

Returns a new ConstraintExpression, which will apply the following constraint to the Length property of the object being tested.

Message

Returns a new ConstraintExpression, which will apply the following constraint to the Message property of the object being tested.

NaN

Returns a constraint that tests for NaN

Negative
No

Returns a ConstraintExpression that negates any following constraint.

None

Returns a ConstraintExpression, which will apply the following constraint to all members of a collection, succeeding if all of them fail.

Not

Returns a ConstraintExpression that negates any following constraint.

Null

Returns a constraint that tests for null

Ordered

Returns a constraint that tests whether a collection is ordered

Positive
Some

Returns a ConstraintExpression, which will apply the following constraint to all members of a collection, succeeding if at least one of them succeeds.

True

Returns a constraint that tests for True

Unique

Returns a constraint that tests whether a collection contains all unique items.

XmlSerializable

Returns a constraint that tests whether an object graph is serializable in xml format.

Methods

AssignableFrom(Type)

Returns a constraint that tests whether the actual value is assignable from the type supplied as an argument.

AssignableFrom<T>()

Returns a constraint that tests whether the actual value is assignable from the type supplied as an argument.

AssignableTo(Type)

Returns a constraint that tests whether the actual value is assignable from the type supplied as an argument.

AssignableTo<T>()

Returns a constraint that tests whether the actual value is assignable from the type supplied as an argument.

AtLeast(Object)

Returns a constraint that tests whether the actual value is greater than or equal to the suppled argument

AtMost(Object)

Returns a constraint that tests whether the actual value is less than or equal to the suppled argument

Attribute(Type)

Returns a new AttributeConstraint checking for the presence of a particular attribute on an object.

Attribute<T>()

Returns a new AttributeConstraint checking for the presence of a particular attribute on an object.

Contains(Object)

Returns a new CollectionContainsConstraint checking for the presence of a particular object in the collection.

Contains(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)

Returns a constraint that succeeds if the actual value contains the substring supplied as an argument.

DoesNotContain(String)

Returns a constraint that fails if the actual value contains the substring supplied as an argument.

DoesNotEndWith(String)

Returns a constraint that fails if the actual value ends with the substring supplied as an argument.

DoesNotMatch(String)

Returns a constraint that fails if the actual value matches the pattern supplied as an argument.

DoesNotStartWith(String)

Returns a constraint that fails if the actual value starts with the substring supplied as an argument.

EndsWith(String)

Returns a constraint that succeeds if the actual value ends with the substring supplied as an argument.

EqualTo(Object)

Returns a constraint that tests two items for equality

EquivalentTo(IEnumerable)

Returns a constraint that tests whether the actual value is a collection containing the same elements as the collection supplied as an argument.

Exactly(Int32)
GreaterThan(Object)

Returns a constraint that tests whether the actual value is greater than the suppled argument

GreaterThanOrEqualTo(Object)

Returns a constraint that tests whether the actual value is greater than or equal to the suppled argument

InRange<T>(T, T)
InstanceOf(Type)

Returns a constraint that tests whether the actual value is of the type supplied as an argument or a derived type.

InstanceOf<T>()

Returns a constraint that tests whether the actual value is of the type supplied as an argument or a derived type.

LessThan(Object)

Returns a constraint that tests whether the actual value is less than the suppled argument

LessThanOrEqualTo(Object)

Returns a constraint that tests whether the actual value is less than or equal to the suppled argument

Matches(String)

Returns a constraint that succeeds if the actual value matches the Regex pattern supplied as an argument.

Member(Object)

Returns a new CollectionContainsConstraint checking for the presence of a particular object in the collection.

Property(String)

Returns a new PropertyConstraintExpression, which will either test for the existence of the named property on the object being tested or apply any following constraint to that property.

SameAs(Object)

Returns a constraint that tests that two references are the same object

SamePath(String)

Returns a constraint that tests whether the path provided is the same as an expected path after canonicalization.

SamePathOrUnder(String)

Returns a constraint that tests whether the path provided is the same path or under an expected path after canonicalization.

StartsWith(String)

Returns a constraint that succeeds if the actual value starts with the substring supplied as an argument.

StringContaining(String)

Returns a constraint that succeeds if the actual value contains the substring supplied as an argument.

StringEnding(String)

Returns a constraint that succeeds if the actual value ends with the substring supplied as an argument.

StringMatching(String)

Returns a constraint that succeeds if the actual value matches the Regex pattern supplied as an argument.

StringStarting(String)

Returns a constraint that succeeds if the actual value starts with the substring supplied as an argument.

SubPath(String)
SubsetOf(IEnumerable)

Returns a constraint that tests whether the actual value is a subset of the collection supplied as an argument.

TypeOf(Type)

Returns a constraint that tests whether the actual value is of the exact type supplied as an argument.

TypeOf<T>()

Returns a constraint that tests whether the actual value is of the exact type supplied as an argument.

Applies to