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