-
Notifications
You must be signed in to change notification settings - Fork 733
Allow using lambdas for asserting the order of elements in collections #1526
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
Allow using lambdas for asserting the order of elements in collections #1526
Conversation
a194f92 to
e71037a
Compare
3d004ba to
9967997
Compare
9967997 to
514ae50
Compare
514ae50 to
40f22da
Compare
|
Rebased on #1529 |
jnyrup
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I never get tired of seeing the capabilities of this library, where you can add a new functionality by adding two one-liners.
For completeness NotBeInAscendingOrder and NotBeInDescendingOrder should also be augmented with the new overloads.
Tests/FluentAssertions.Specs/Collections/GenericCollectionAssertionOfStringSpecs.cs
Outdated
Show resolved
Hide resolved
40f22da to
493248a
Compare
|
Now I think of it... Why don't we just add |
Why didn't I think of this myself... |
493248a to
d26a4c5
Compare
Src/FluentAssertions/Collections/GenericCollectionAssertions.cs
Outdated
Show resolved
Hide resolved
Src/FluentAssertions/Collections/GenericCollectionAssertions.cs
Outdated
Show resolved
Hide resolved
30b8ff3 to
08f0d51
Compare
docs/_pages/collections.md
Outdated
| collection.Should().NotIntersectWith(anotherCollection); | ||
| ``` | ||
|
|
||
| Asserting that a collection contains items in a certain order is as easy as using one of the several overloads of `BeInAscendingOrder` or `BeInDescendingOrder`. The default overload will use the default `Comparer` for the specified type, but overloads also exist that take an `IComparer<T>`, a property expression to sort by an object's property, or a lambda expression to avoid the need for `ICompare<T>` implementations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ICompare<T> -> IComparer<T>
…aking a lambda expression
08f0d51 to
99f46f2
Compare
jnyrup
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
![]()
|
Thanks for improving this! |
Added
BeInAscendingOrderandBeInDescendingOrdertostringcollections taking either anIComparer<string>or a lambda expressionFixes #998