Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ShouldAllBe with predicate signature Expression<Func<T, int, bool>> (like in LINQ where clause) #842

Open
makeit-mh opened this issue Jul 8, 2022 · 2 comments

Comments

@makeit-mh
Copy link

makeit-mh commented Jul 8, 2022

I'm looking for ShouldAllBe with predicate signature Expression<Func<T, int, bool>> (like in LINQ where clause). Where is it? I want do something like this:
result.ShouldAllBe((item ,index ) => item.No== index);
How can I achive something like this?

@jnm2
Copy link
Collaborator

jnm2 commented Oct 4, 2022

You can currently achieve this via:

result.Select((item, index) => (item, index)).ShouldAllBe(entry => entry.item.No == entry.index);

Or if you define your own AsIndexed extension method or similar, which many do:

result.AsIndexed().ShouldAllBe(entry => entry.Value.No == entry.Index);

@makeit-mh
Copy link
Author

It works. Thanks! ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants