Git Product home page Git Product logo

Comments (5)

Meir017 avatar Meir017 commented on May 31, 2024 1

@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

from fluentassertions.analyzers.

Meir017 avatar Meir017 commented on May 31, 2024

should this case be ignored?

there is an overload HaveCount(Expression<Func<int, bool>> countPredicate, string because = "", params object[] becauseArgs) but I'm not sure how to use it.
@dennisdoomen is it possible to write the assertion using this overload?

from fluentassertions.analyzers.

jnyrup avatar jnyrup commented on May 31, 2024

If you're updating the docs, there is a related example in there:

- old: |
    actual.Where(x => x.SomeProperty).Should().HaveCount(1);
  new: |
    actual.Should().ContainSingle(x => x.SomeProperty);

https://github.com/fluentassertions/fluentassertions/blob/88c4fd6ff7c5444b46096553ea7bd2e3df804289/docs/_data/tips/collections.yml#L248

And I would probably replace

list.Count(e => e > 1).Should().Be(2);

with

list.Where(e => e > 1).Should().HaveCount(2);

from fluentassertions.analyzers.

dennisdoomen avatar dennisdoomen commented on May 31, 2024

When using the Count method with a predicate overload the predicate is not taken into account.

What do you mean with that? The Count is an LINQ extension method. The resulting IEnumerable<T> should return a lazy evaluated filter.

from fluentassertions.analyzers.

jnyrup avatar jnyrup commented on May 31, 2024

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

from fluentassertions.analyzers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.