Class StartsWithConstraint
StartsWithConstraint can test whether a string starts with an expected substring.
Inherited Members
Namespace: NUnit.Framework.Constraints
Assembly: nunit.framework.dll
Syntax
public class StartsWithConstraint : StringConstraint, IConstraint, IResolveConstraint
Constructors
View SourceStartsWithConstraint(string)
Initializes a new instance of the StartsWithConstraint class.
Declaration
public StartsWithConstraint(string expected)
Parameters
| Type | Name | Description |
|---|---|---|
| string | expected | The expected string |
Methods
View SourceMatches(string?)
Determines whether the actual string value starts with the expected substring.
Declaration
protected override bool Matches(string? actual)
Parameters
| Type | Name | Description |
|---|---|---|
| string | actual | The string value to test. |
Returns
| Type | Description |
|---|---|
| bool |
Overrides
View SourceMatches(string?, CultureInfo)
Determines whether the actual string value starts with the expected substring,
using the specified CultureInfo and case sensitivity specified by the constraint.
If cultureInfo is not null, the comparison uses culture-specific rules;
otherwise, it falls back to the default string comparison logic.
Declaration
protected override bool Matches(string? actual, CultureInfo cultureInfo)
Parameters
| Type | Name | Description |
|---|---|---|
| string | actual | The string value to test. |
| CultureInfo | cultureInfo | The culture information to use for the comparison. |
Returns
| Type | Description |
|---|---|
| bool |
Overrides
View SourceMatches(string?, StringComparison)
Determines whether the actual string value starts with the expected substring, using the specified string comparison.
Declaration
protected override bool Matches(string? actual, StringComparison stringComparison)
Parameters
| Type | Name | Description |
|---|---|---|
| string | actual | The string value to test. |
| StringComparison | stringComparison | The string comparison to use. |
Returns
| Type | Description |
|---|---|
| bool |