question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Count with predicate

See original GitHub issue

When 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:closed
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Meir017commented, Oct 23, 2017

@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

0reactions
jnyrupcommented, Oct 23, 2017

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found