Table of Contents

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 string

The expected.

Properties

IgnoreCase

Modify the constraint to ignore case in matching. This will call Using(StringComparison.CurrentCultureIgnoreCase).

public override StringConstraint IgnoreCase { get; }

Property Value

StringConstraint

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 string

The 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

SubstringConstraint

Exceptions

InvalidOperationException

Thrown when a comparison type different than comparisonType was already set.