Class SubstringConstraint
- Namespace
- NUnit.Framework.Constraints
- Assembly
- nunit.framework.dll
SubstringConstraint can test whether a string contains the expected substring.
public class SubstringConstraint : StringConstraint, IConstraint, IResolveConstraint
- Inheritance
-
SubstringConstraint
- Implements
- Inherited Members
Constructors
SubstringConstraint(string)
Initializes a new instance of the SubstringConstraint class.
public SubstringConstraint(string expected)
Parameters
expected
stringThe expected.
Properties
IgnoreCase
Modify the constraint to ignore case in matching. This will call Using(StringComparison.CurrentCultureIgnoreCase).
public override StringConstraint IgnoreCase { get; }
Property Value
Exceptions
- InvalidOperationException
Thrown when a comparison type different than CurrentCultureIgnoreCase was already set.
Methods
Matches(string)
Test whether the constraint is satisfied by a given value
protected override bool Matches(string actual)
Parameters
actual
stringThe value to be tested
Returns
- bool
True for success, false for failure
Using(StringComparison)
Modify the constraint to the specified comparison.
public SubstringConstraint Using(StringComparison comparisonType)
Parameters
comparisonType
StringComparison
Returns
Exceptions
- InvalidOperationException
Thrown when a comparison type different than
comparisonType
was already set.