Table of Contents

Class StringConstraint

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

StringConstraint is the abstract base for constraints that operate on strings. It supports the IgnoreCase modifier for string operations.

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

Constructors

StringConstraint()

Constructs a StringConstraint without an expected value

protected StringConstraint()

StringConstraint(string)

Constructs a StringConstraint given an expected value

protected StringConstraint(string expected)

Parameters

expected string

The expected value

Fields

caseInsensitive

Indicates whether tests should be case-insensitive

protected bool caseInsensitive

Field Value

bool

descriptionText

Description of this constraint

protected string descriptionText

Field Value

string

expected

The expected value

protected string expected

Field Value

string

Properties

Description

The Description of what this constraint tests, for use in messages and in the ConstraintResult.

public override string Description { get; }

Property Value

string

IgnoreCase

Modify the constraint to ignore case in matching.

public StringConstraint IgnoreCase { get; }

Property Value

StringConstraint

Methods

ApplyTo<TActual>(TActual)

Test whether the constraint is satisfied by a given value

public override ConstraintResult ApplyTo<TActual>(TActual actual)

Parameters

actual TActual

The value to be tested

Returns

ConstraintResult

True for success, false for failure

Type Parameters

TActual

Matches(string)

Test whether the constraint is satisfied by a given string

protected abstract bool Matches(string actual)

Parameters

actual string

The string to be tested

Returns

bool

True for success, false for failure