Class ExactCountConstraint
ExactCountConstraint applies another constraint to each item in a collection, succeeding only if a specified number of items succeed.
Inherited Members
Namespace: NUnit.Framework.Constraints
Assembly: nunit.framework.dll
Syntax
public class ExactCountConstraint : Constraint, IEnumerableConstraint, IConstraint, IResolveConstraint
Constructors
View SourceExactCountConstraint(int)
Construct a standalone ExactCountConstraint
Declaration
public ExactCountConstraint(int expectedCount)
Parameters
| Type | Name | Description |
|---|---|---|
| int | expectedCount |
ExactCountConstraint(int, IConstraint)
Construct an ExactCountConstraint on top of an existing constraint
Declaration
public ExactCountConstraint(int expectedCount, IConstraint itemConstraint)
Parameters
| Type | Name | Description |
|---|---|---|
| int | expectedCount | |
| IConstraint | itemConstraint |
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
Methods
View SourceApplyToEnumerable<TActual, TItem>(TActual, IEnumerable<TItem>)
Apply the item constraint to each item in the collection, succeeding only if the expected number of items pass.
Declaration
public ConstraintResult ApplyToEnumerable<TActual, TItem>(TActual actual, IEnumerable<TItem> enumerable)
Parameters
| Type | Name | Description |
|---|---|---|
| TActual | actual | The value that the collection originated from |
| IEnumerable<TItem> | enumerable | The collection to be tested |
Returns
| Type | Description |
|---|---|
| ConstraintResult | A ConstraintResult |
Type Parameters
| Name | Description |
|---|---|
| TActual | |
| TItem |
ApplyTo<TActual>(TActual)
Apply the item constraint to each item in the collection, succeeding only if the expected number of items pass.
Declaration
public override ConstraintResult ApplyTo<TActual>(TActual actual)
Parameters
| Type | Name | Description |
|---|---|---|
| TActual | actual | The value to be tested |
Returns
| Type | Description |
|---|---|
| ConstraintResult | A ConstraintResult |
Type Parameters
| Name | Description |
|---|---|
| TActual |