Table of Contents

Class Is

Namespace
NUnit.Framework
Assembly
nunit.framework.dll

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

public class Is
Inheritance
Is
Derived
Inherited Members

Constructors

Is()

public Is()

Properties

All

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

public static ConstraintExpression All { get; }

Property Value

ConstraintExpression

BinarySerializable

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

public static BinarySerializableConstraint BinarySerializable { get; }

Property Value

BinarySerializableConstraint

Empty

Returns a constraint that tests for empty

public static EmptyConstraint Empty { get; }

Property Value

EmptyConstraint

False

Returns a constraint that tests for False

public static FalseConstraint False { get; }

Property Value

FalseConstraint

NaN

Returns a constraint that tests for NaN

public static NaNConstraint NaN { get; }

Property Value

NaNConstraint

Negative

Returns a constraint that tests for a negative value

public static LessThanConstraint Negative { get; }

Property Value

LessThanConstraint

Not

Returns a ConstraintExpression that negates any following constraint.

public static ConstraintExpression Not { get; }

Property Value

ConstraintExpression

Null

Returns a constraint that tests for null

public static NullConstraint Null { get; }

Property Value

NullConstraint

Ordered

Returns a constraint that tests whether a collection is ordered

public static CollectionOrderedConstraint Ordered { get; }

Property Value

CollectionOrderedConstraint

Positive

Returns a constraint that tests for a positive value

public static GreaterThanConstraint Positive { get; }

Property Value

GreaterThanConstraint

True

Returns a constraint that tests for True

public static TrueConstraint True { get; }

Property Value

TrueConstraint

Unique

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

public static UniqueItemsConstraint Unique { get; }

Property Value

UniqueItemsConstraint

XmlSerializable

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

public static XmlSerializableConstraint XmlSerializable { get; }

Property Value

XmlSerializableConstraint

Methods

AssignableFrom(Type)

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

public static AssignableFromConstraint AssignableFrom(Type expectedType)

Parameters

expectedType Type

Returns

AssignableFromConstraint

AssignableFrom<TExpected>()

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

public static AssignableFromConstraint AssignableFrom<TExpected>()

Returns

AssignableFromConstraint

Type Parameters

TExpected

AssignableTo(Type)

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

public static AssignableToConstraint AssignableTo(Type expectedType)

Parameters

expectedType Type

Returns

AssignableToConstraint

AssignableTo<TExpected>()

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

public static AssignableToConstraint AssignableTo<TExpected>()

Returns

AssignableToConstraint

Type Parameters

TExpected

AtLeast(object)

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

public static GreaterThanOrEqualConstraint AtLeast(object expected)

Parameters

expected object

Returns

GreaterThanOrEqualConstraint

AtMost(object)

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

public static LessThanOrEqualConstraint AtMost(object expected)

Parameters

expected object

Returns

LessThanOrEqualConstraint

EqualTo(object)

Returns a constraint that tests two items for equality

public static EqualConstraint EqualTo(object expected)

Parameters

expected object

Returns

EqualConstraint

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.

public static CollectionEquivalentConstraint EquivalentTo(IEnumerable expected)

Parameters

expected IEnumerable

Returns

CollectionEquivalentConstraint

GreaterThan(object)

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

public static GreaterThanConstraint GreaterThan(object expected)

Parameters

expected object

Returns

GreaterThanConstraint

GreaterThanOrEqualTo(object)

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

public static GreaterThanOrEqualConstraint GreaterThanOrEqualTo(object expected)

Parameters

expected object

Returns

GreaterThanOrEqualConstraint

InRange(IComparable, IComparable)

Returns a constraint that tests whether the actual value falls inclusively within a specified range.

public static RangeConstraint InRange(IComparable from, IComparable to)

Parameters

from IComparable

Inclusive beginning of the range. Must be less than or equal to to.

to IComparable

Inclusive end of the range. Must be greater than or equal to from.

Returns

RangeConstraint

Remarks

from must be less than or equal to true

InstanceOf(Type)

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

public static InstanceOfTypeConstraint InstanceOf(Type expectedType)

Parameters

expectedType Type

Returns

InstanceOfTypeConstraint

InstanceOf<TExpected>()

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

public static InstanceOfTypeConstraint InstanceOf<TExpected>()

Returns

InstanceOfTypeConstraint

Type Parameters

TExpected

LessThan(object)

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

public static LessThanConstraint LessThan(object expected)

Parameters

expected object

Returns

LessThanConstraint

LessThanOrEqualTo(object)

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

public static LessThanOrEqualConstraint LessThanOrEqualTo(object expected)

Parameters

expected object

Returns

LessThanOrEqualConstraint

SameAs(object)

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

public static SameAsConstraint SameAs(object expected)

Parameters

expected object

Returns

SameAsConstraint

SamePath(string)

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

public static SamePathConstraint SamePath(string expected)

Parameters

expected string

Returns

SamePathConstraint

SamePathOrUnder(string)

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

public static SamePathOrUnderConstraint SamePathOrUnder(string expected)

Parameters

expected string

Returns

SamePathOrUnderConstraint

StringContaining(string)

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

[Obsolete("Deprecated, use Does.Contain")]
public static SubstringConstraint StringContaining(string expected)

Parameters

expected string

Returns

SubstringConstraint

StringEnding(string)

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

[Obsolete("Deprecated, use Does.EndWith")]
public static EndsWithConstraint StringEnding(string expected)

Parameters

expected string

Returns

EndsWithConstraint

StringMatching(string)

Returns a constraint that succeeds if the actual value matches the regular expression supplied as an argument.

[Obsolete("Deprecated, use Does.Match")]
public static RegexConstraint StringMatching(string pattern)

Parameters

pattern string

Returns

RegexConstraint

StringStarting(string)

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

[Obsolete("Deprecated, use Does.StartWith")]
public static StartsWithConstraint StringStarting(string expected)

Parameters

expected string

Returns

StartsWithConstraint

SubPathOf(string)

Returns a constraint that tests whether the path provided is a subpath of the expected path after canonicalization.

public static SubPathConstraint SubPathOf(string expected)

Parameters

expected string

Returns

SubPathConstraint

SubsetOf(IEnumerable)

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

public static CollectionSubsetConstraint SubsetOf(IEnumerable expected)

Parameters

expected IEnumerable

Returns

CollectionSubsetConstraint

SupersetOf(IEnumerable)

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

public static CollectionSupersetConstraint SupersetOf(IEnumerable expected)

Parameters

expected IEnumerable

Returns

CollectionSupersetConstraint

TypeOf(Type)

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

public static ExactTypeConstraint TypeOf(Type expectedType)

Parameters

expectedType Type

Returns

ExactTypeConstraint

TypeOf<TExpected>()

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

public static ExactTypeConstraint TypeOf<TExpected>()

Returns

ExactTypeConstraint

Type Parameters

TExpected