feat: add collection count range assertions#4937
Conversation
Code ReviewIssue: Missing Public API Snapshot UpdatesThe PR adds significant new public API surface to New public types added (6 classes):
New public methods added (9 methods):
Per CLAUDE.md:
The To fix: Run the snapshot tests, then promote the generated # After running snapshot tests, from the repo root:
for f in TUnit.PublicAPI/*.received.txt; do mv "$f" "${f%.received.txt}.verified.txt"; done
git add TUnit.PublicAPI/*.verified.txtOverall AssessmentAside from the missing snapshot updates, the implementation is well-structured and follows the established manual pattern correctly — which is the right approach for collection assertions. The |
36d06e6 to
1db109f
Compare
1db109f to
42afa53
Compare
42afa53 to
9d4d050
Compare
…asCountBetween) Add three new collection count assertions for more expressive range checking: - HasAtLeast(minCount): asserts collection count >= minCount - HasAtMost(maxCount): asserts collection count <= maxCount - HasCountBetween(min, max): asserts min <= collection count <= max Implemented for both IEnumerable<T> (via CollectionAssertionBase) and IAsyncEnumerable<T> (via AsyncEnumerableAssertionBase), following existing patterns with CollectionChecks delegation and EnumerableAdapter usage. Closes #4869
Add verified snapshots for HasAtLeast, HasAtMost, and HasCountBetween assertion methods added to the collection assertions API.
9d4d050 to
3eadfc9
Compare
Add Defaults class, SetRetryBackoff method, BackoffMs/BackoffMultiplier properties on RetryAttribute, RetryBackoffMs/RetryBackoffMultiplier on TestDetails and ITestConfiguration - matching the DotNet8_0 snapshot but without DynamicallyAccessedMembers annotations.
Summary
HasAtLeast(int minCount)assertion: asserts collection has >= minCount itemsHasAtMost(int maxCount)assertion: asserts collection has <= maxCount itemsHasCountBetween(int min, int max)assertion: asserts collection count is between min and max (inclusive)IEnumerable<T>andIAsyncEnumerable<T>following existing patterns.And/.OrcontinuationsCloses #4869
Test plan
HasAtLeastpasses when collection count >= minCount and fails when count < minCountHasAtMostpasses when collection count <= maxCount and fails when count > maxCountHasCountBetweenpasses when min <= count <= max and fails otherwise.HasAtLeast(2).And.HasAtMost(5))