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
Provide opt-out to AssertionOptions(o => o.WithStrictOrdering())
#966
Comments
EquivalencyAssertionOptions<T>.WithoutStrictOrdering()
to revert AssertionOptions(o => o.WithStrictOrdering())
EquivalencyAssertionOptions<T>.WithoutStrictOrdering()
to revert AssertionOptions(o => o.WithStrictOrdering())
EquivalencyAssertionOptions<T>.WithoutStrictOrdering()
to revert AssertionOptions(o => o.WithStrictOrdering())
AssertionOptions(o => o.WithStrictOrdering())
@dennisdoomen I could provide a PR. I'm not really sure how to implement the feature, though, because...
I believe:
I currently believe the simplest behavior would be
and thus where the vision should lead us. However, how much of a breaking change is this? If this is too much of a breaking change, what would be the best acceptable change leading us in the right direction and resolving the issue? |
What I don't understand is how this worked in previous versions. The code around ordering hasn't been changed for 9 months or so. That being said, I think multiple calls to |
Allowed in the sense of not throwing an exception? But what is the expected effect on the comparison? Do the two variants of the following examples always behave the same or is there a difference? Example 1
versus
Example 2
versus
|
Example 2 should be the same as |
Is it possible that the original issue that you raised is now fixed by #967 ? |
@BrunoJuchli Can you check if the failing tests contain empty lists? |
@dennisdoomen Thanks,yes, most likely it's fixed by #967 I believe it's still valuable to have the API allow overriding of defaults configured by The implementation of FluentAssertions, however, does not actually override the default but rather complement it by adding a "filter" which reverses the effect of - the still configured - Thus, if this is ok with you, I'd try to provide a PR, adapting the implementation to:
And tests, of course:
and vice versa for |
Sure. I'll change the label. |
Should
Personally, it seems risky to have Having
from a usage perspective I'd prefer this. |
I think you'll need to collect all ordering rules in some kind of collection and then evaluate the resulting ordering based on the order of the rules. |
Taken care of by #974 |
Breaking change in 5.5 (coming from 5.4.2)
We globally set the default assertion equivalency options using:
Because we believe it's safer to require strict ordering by default (I can provide a reasoning if anyone is interested).
Now, in special cases where the order did not matter, we used:
to counteract the effect of
WithStrictOrdering()
. For certain scenarios this has stopped working with 5.5.0 (we now have a test fail which didn't fail before).Proposal
WithoutStrictOrderingFor(info => true))
was a bit of an ugly workaround in the first place.Instead of "reverting" FluentAssertions to work as before it seems more sensible to actually support
WithoutStrictOrdering
as a proper counterpart toWithStrictOrdering
.SelfReferenceEquivalencyAssertionOptions<TSelf>.WithStrictOrdering()
performs
The suggested
SelfReferenceEquivalencyAssertionOptions<TSelf>.WithoutStrictOrdering()
should perform something along the lines of:Complete minimal example reproducing the issue
I have taken the liberty of not providing a repro - for now. If necessary I can produce one, but since I don't really consider the 5.5 behavior a bug It seems more appropriate to focus on the feature request - which, I believe, does resolve the issue appropriately.
Note: I suspect this to be connected to #965
the reason is that this problem only surfaces in a very few tests even though we apply
WithoutStrictOrderingFor(info => true)
166 times.Please also note that I have tested the following cases:
Default
WithStrictOrdering
, override withWithoutStrictOrderingFor(info => true)
--> used to work in 5.4.2
--> doesn't work in 5.5 (i.E. breaking change)
Default
WithStrictOrdering
, noWithoutStrictOrderingFor
, expected and actual sequence match--> works in 5.5 (expected)
Default without strict ordering, no
WithoutStrictOrderingFor
--> works in 5.5 (expected)
Versions
The text was updated successfully, but these errors were encountered: