Skip to content

Dictionary assertions do not use the equality comparer of the dictionary involved #1232

@rubenrorije

Description

@rubenrorije

I noticed in the source code that GenericDictionaryAssertions uses intersect to compare the keys from the dictionary and the unexpected keys, which does not use the equality comparer of the dictionary. The dual ContainKeys implementation as well as the other methods all use the ContainsKey on the dictionary which is correct.

To illustrate the issue I added two unit tests and changed the implementation in the pull request.

I also updated the xml documentation of all (Not)ContainKey(s) to reflect the code. The documentation was saying that the keys were compared using object.Equals which is not the case in the code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions