arcus-azure / arcus.testing

Reusable testing components used during Arcus testing.
https://testing.arcus-azure.net/
MIT License
5 stars 2 forks source link

JsonAssert: Issue when comparing unordered array of Json objects #151

Closed ClementVaillantCodit closed 3 months ago

ClementVaillantCodit commented 3 months ago

Describe the bug When comparing unordered Json array of objects, the comparison fails even when using AssertJsonOrder.Ignore.

To Reproduce

        string actual = "{\"Products\":[{\"id\":1},{\"id\":2},{\"id\":3}]}";
        string expected = "{\"Products\":[{\"id\":3},{\"id\":2},{\"id\":1}]}";

        EqualJson(expected, actual);

Comparison fails.

Please see: https://github.com/Codit/testing-framework/blob/main/src/Codit.Testing.OutputComparison/Helper/Json.cs#L62 Testing framework was handling this case.

Expected behavior Comparison must pass as array of objects have equal but unordered objects.

Additional context

stijnmoreels commented 3 months ago

This is actually expected, as they are objects and we can't determine the order of objects.