nunit: Breaking change in CollectionAssert.AllItemsAreUnique with NUnit 3.9
After upgrading to NUnit Framework 3.9 we have a failing test that checks if all items of an object collection are unique. Example:
var collection = new Collection<object> {42, null, 42f};
Assert.That(
() => CollectionAssert.AllItemsAreUnique(collection),
Throws.TypeOf<AssertionException>());
A float value of 42f now is considered to be different to an integer value 42.
Is this intentional or an undesirable side effect of maybe #2551?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 17 (17 by maintainers)
Commits related to this issue
- Use NUnit equality when the element type is not sealed Fixes #2627 — committed to nunit/nunit by mikkelbu 6 years ago
@rprouse Actually, I’ve not had time to look at this yet, but I think that I’ll have time to do it this weekend.
Sure. I can take a look at it.
I think the problem was introduced in #2501 since we dont say that
int/floatareIsHandledSpeciallyByNUnitthen we will just hash them and I guess that the hashcode for42is different from that of42f.