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.

Add Should().All() feature

See original GitHub issue

I very often want to make an assertion about every member of a collection. You can use .Should().OnlyContain() but I’d like to be able to use your lovely library of helper assertions.

e.g. I’d like to be able to write: myStrings.Should().All().StartWith("Hello");

It feels like it ought to be relatively achievable? Roughly speaking .All() would need to return an object that looked the same as a .Should() of the Collection contents but which passes all of its implementations down to an inner .Should() against each of the elements.

First Question: Would you be happy with this functionality existing?

Second Question: Is this something that you’d be likely to implement any time soon? If not, would you accept a PR for it? And do you think such a change would be tractable to an experienced .NET programmer who’s never looked inside your codebase before?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:16 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
Brondahlcommented, Nov 7, 2019

Some other viable-but-a-bit-dissappointing solutions exist here:

https://stackoverflow.com/questions/18899755/how-to-assert-all-items-in-a-collection-using-fluent-assertions

The .Select() and .ForEach() forms even give access to the assertion helpers. But I think the above proposal is much more inline with the “Fluent” goal of this library, is a LOT more discoverable, and would be much more pleasant all-round.

2reactions
dennisdoomencommented, May 1, 2020

No worries. Life of an open-source developers is unpredictable at best.

I don’t think we should go in that direction. It will create quite a maintenance burden for the future. Maybe a Should().AllSatisfy is a better alternative.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Introduction - Fluent Assertions
One neat feature is the ability to chain a specific assertion on top of an assertion that acts on a collection or graph...
Read more >
SUMIF function
You use the SUMIF function to sum the values in a range that meet criteria that you specify. For example, suppose that in...
Read more >
Python's assert: Debug and Test Your Code Like a Pro
The all() assertions check if all the items in an input iterable are truthy, while the any() examples check if any item in...
Read more >
Assertions | Cypress Documentation
should() command. Cypress will automatically retry the callback function until it passes or the command times out. See the .should() documentation.
Read more >
add_theme_support() | Function
This feature enables plugins and themes to manage the document title tag. This should be used in place of wp_title() function. Copy. add_theme_support(...
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