Count with predicate
See original GitHub issueWhen using the Count method with a predicate overload the predicate is not taken into account.
list.Count(e => e > 1).Should().Be(2);
is simplified into:
list.Should().HaveCount(2);
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
c# - Count words using Predicate
I need to get the count of items specified in a string[] which satisfies my condition. So, I tried Predicate and defined my...
Read more >Counting predicates | Better world by better software
It is simple to find every number in the given Array function isNumber(x) { return typeof x === 'number'; } var list =...
Read more >Counting elements meeting a predicate in an enumerable ...
In many cases (at least in my usage) I want to determine if a sequence (or IEnumerable ) has at least a certain...
Read more >Count - Using C# LINQ - A Practical Overview
Count (<predicate>) method. There is another form of the Count() method that takes a predicate delegate parameter. The provided delegate should take a...
Read more >Count items in a List matching a predicate in Kotlin
This article explores different ways to count items in a list matching a predicate in Kotlin. 1. Using size property. The standard solution...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@dennisdoomen he was talking about the analyzer…
I meant that I wanted to see if it was possible to rewrite the assertion using that overload
@dennisdoomen The “not taken in to account” is my attempt to blame the computer rather than @Meir017’s great work.
When using The
Count
method from LINQ that takes an predicate, the simplified assertion produced by the analyzer no longer contains the predicate.