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
Extend GenericCollectionAssertions
to include a ContainInConsecutiveOrder
#1956
Comments
The changes we have made can be seen here: develop...StacyCash:fluentassertions:develop |
I think it makes total sense. What about you @jnyrup ? |
GenericCollectionAssertions
to include a ContainsInConsecutiveOrder
GenericCollectionAssertions
to include a ContainInConsecutiveOrder
What do you think about an option for |
@lg2de I'm curious where you find we get a better overview with the lambda approach? The general design has been that assertions are most discoverable when they are directly available from IntelliSense after writing I recall the API some years ago allowed/required one to pass in the That said, I'm not opposed to the idea of also having overloads that lets you write something like this. subject.Should().Contain(expected);
subject.Should().Contain(expected, e => e.InOrder());
subject.Should().Contain(expected, e => e.InConsecutiveOrder()); Off the top of my head I can't recall if we have any principles about having multiple entries to the same assertion. |
From my point of view all options are discoverable in IntelliSense either way. But they are not in parallel but stacked. This helps in my eyes for an better overview.
I have not seen that before and it may be confusing. Then it would be more difficult to know whether BTW: This is an example where I think "one method with multiple options" could be easier to understand because the code will get more explicit, e.g.: |
Although I don't dislike the proposal, my problem is that we already took a certain (ad-hoc) path where we have distinct methods for distinct goals. If we would have taken this design principle as a starting point, we could have done that. And we still can, but it would be a major breaking change that would require a major review of all APIs to see what they would look like in a major new version. Not only would this require a lot of work and planning, it would also be a major breaking change for our installed base without gaining a lot. |
I'm good with @lg2de Thanks for your perspectives (here and elsewhere in the repo). |
Can I create PR based on the linked repo and this issue? Or is there a process that needs to be gone through first? |
If you create a PR and link it to this issue it's perfect. Btw, this issue inspired me to the optimizations in #1960 and a similar approach could be applied to Take this pseudo code
|
Brilliant, I'll get it updated and the PR created tomorrow 😊 |
Description
We were writing tests where we needed to check if one collection contained another in order. For this, we used
ContainInOrder
.However, we found that because
ContainInOrder
doesn't check that the items are consecutive we could introduce mutations in the code and our tests would still pass.To solve this we have made a new method in the same class,
GenericCollectionAssertions
, calledContainInConsecutiveOrder
. This is a stricter version of the current check, adding the check that the expected items all appear in consecutive order. For completeness, we also introduced the oppositeNotContainInConsecutiveOrder
.The API change is an extension to the API, with, as far as I can see, no breaking changes.
We have implemented these changes, with associated tests, in a branch and would like to submit a PR.
The text was updated successfully, but these errors were encountered: