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

Most upvoted comments

@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/float are IsHandledSpeciallyByNUnit then we will just hash them and I guess that the hashcode for 42 is different from that of 42f.