Table of Contents

Class RegexConstraint

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

RegexConstraint can test whether a string matches the pattern provided.

public class RegexConstraint : Constraint, IConstraint, IResolveConstraint
Inheritance
RegexConstraint
Implements
Inherited Members

Constructors

RegexConstraint(string)

Initializes a new instance of the RegexConstraint class.

public RegexConstraint(string pattern)

Parameters

pattern string

The pattern.

RegexConstraint(Regex)

Initializes a new instance of the RegexConstraint class.

public RegexConstraint(Regex regex)

Parameters

regex Regex

The Regex pattern object.

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 RegexConstraint IgnoreCase { get; }

Property Value

RegexConstraint

Methods

ApplyTo<TActual>(TActual)

Applies the regex constraint to an actual value, returning a ConstraintResult.

public override ConstraintResult ApplyTo<TActual>(TActual actual)

Parameters

actual TActual

The string to be tested.

Returns

ConstraintResult

True for success, false for failure.

Type Parameters

TActual