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
stringThe pattern.
RegexConstraint(Regex)
Initializes a new instance of the RegexConstraint class.
public RegexConstraint(Regex regex)
Parameters
regex
RegexThe 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
IgnoreCase
Modify the constraint to ignore case in matching.
public RegexConstraint IgnoreCase { get; }
Property Value
Methods
ApplyTo<TActual>(TActual)
Applies the regex constraint to an actual value, returning a ConstraintResult.
public override ConstraintResult ApplyTo<TActual>(TActual actual)
Parameters
actual
TActualThe string to be tested.
Returns
- ConstraintResult
True for success, false for failure.
Type Parameters
TActual