<PackageReference Include="NUnit" Version="4.2.1" />

ExactCountOperator

Represents a constraint that succeeds if the specified count of members of a collection match a base constraint.
using System.Runtime.CompilerServices; namespace NUnit.Framework.Constraints { public class ExactCountOperator : SelfResolvingOperator { private readonly int _expectedCount; public ExactCountOperator(int expectedCount) { left_precedence = 1; right_precedence = 10; _expectedCount = expectedCount; } [System.Runtime.CompilerServices.NullableContext(1)] public override void Reduce(ConstraintBuilder.ConstraintStack stack) { if (base.RightContext == null || base.RightContext is BinaryOperator) stack.Push(new ExactCountConstraint(_expectedCount)); else stack.Push(new ExactCountConstraint(_expectedCount, stack.Pop())); } } }