Skip to content

Commit 39a9ed5

Browse files
authored
fix(tests): unbreak main - disambiguate Count overload after IsEqualTo wrappers (#5751) (#5759)
* fix(tests): disambiguate Count overload broken by IsEqualTo wrappers (#5751) Chained_Collection_Assertions_WithStrings called .Count(c => c.IsEqualTo(3)) on string[]. Before #5751 this failed to bind to the per-item filter overload (int-vs-string mismatch on IsEqualTo) and resolved to the inline-count assertion form, returning a chainable assertion. After #5751 added IsEqualTo<TValue, TOther> with implicit-conversion fallback, both overloads compile and resolution picks the per-item filter, which returns CollectionCountSource<,> -- a count source without .And -- breaking .And.Contains("Bob") with CS1061. Mirror the int test (Chained_Collection_Assertions) and use .Count().IsEqualTo(3) so the resulting assertion is the chainable CollectionCountEqualsAssertion regardless of TItem. * fix(tests): tighten Count overload comment
1 parent 3a4312f commit 39a9ed5

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

TUnit.Assertions.Tests/CollectionAssertionTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,10 @@ public async Task Chained_Collection_Assertions_WithStrings()
263263
{
264264
var names = new[] { "Alice", "Bob", "Charlie" };
265265

266-
// For non-int collections, Count(c => c.IsEqualTo(3)) works unambiguously
266+
// Count(predicate) is the per-item filter overload and returns a source without .And.
267267
await Assert.That(names)
268268
.IsNotEmpty()
269-
.And.Count(c => c.IsEqualTo(3))
269+
.And.Count().IsEqualTo(3)
270270
.And.Contains("Bob")
271271
.And.DoesNotContain("Dave");
272272
}

0 commit comments

Comments
 (0)