Skip to content

[Feature]: SetEquals, unordered equal for collections #2650

@philipborg

Description

@philipborg

Background and motivation

We are working a lot with sets, like ImmutableHashSet, and often want to assert the equivalent of SetEquals between two sets. There is no offered API for this that I am aware of. I assume that the desired API in question wouldn't be concerned with sets specifically but just unordered equal for GenericCollectionAssertions, which would be functionally enough for the concerned use case.

Alternative Concerns

  • The Equal methods is explicitly ordered so it's not a replacement.
  • BeEquivalentTo does Equivalent comparison rather than equal, which is often not desired.
  • Calling .SetEquals(expectation).Should().BeTrue() has the issue of giving poor failure messages. If the assertion fails you want to see the difference between them.
  • Equals is not implemented on almost any set implementation.

Are you willing help with a pull-request?

Yes, please assign this issue to me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-suggestionEarly API idea and discussion, it is NOT ready for implementationfeature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions