Class ContainsConstraint
ContainsConstraint tests a whether a string contains a substring or a collection contains an object. It postpones the decision of which test to use until the type of the actual argument is known. This allows testing whether a string is contained in a collection or as a substring of another string using the same syntax.
Inherited Members
Namespace: NUnit.Framework.Constraints
Assembly: nunit.framework.dll
Syntax
public class ContainsConstraint : Constraint, IConstraint, IResolveConstraint
Constructors
View SourceContainsConstraint(object?)
Initializes a new instance of the ContainsConstraint class.
Declaration
public ContainsConstraint(object? expected)
Parameters
Type | Name | Description |
---|---|---|
object | expected | The expected value contained within the string/collection. |
Properties
View SourceDescription
The Description of what this constraint tests, for use in messages and in the ConstraintResult.
Declaration
public override string Description { get; }
Property Value
Type | Description |
---|---|
string |
Overrides
View SourceIgnoreCase
Flag the constraint to ignore case and return self.
Declaration
public ContainsConstraint IgnoreCase { get; }
Property Value
Type | Description |
---|---|
ContainsConstraint |
IgnoreWhiteSpace
Flag the constraint to ignore white-space and return self.
Declaration
public ContainsConstraint IgnoreWhiteSpace { get; }
Property Value
Type | Description |
---|---|
ContainsConstraint |
Methods
View SourceApplyTo<TActual>(TActual)
Test whether the constraint is satisfied by a given value
Declaration
public override ConstraintResult ApplyTo<TActual>(TActual actual)
Parameters
Type | Name | Description |
---|---|---|
TActual | actual | The value to be tested |
Returns
Type | Description |
---|---|
ConstraintResult | True for success, false for failure |
Type Parameters
Name | Description |
---|---|
TActual |