Skip to content

Commit b45cc22

Browse files
committed
add paragraph about WithoutStrictOrdering in README.md
1 parent 424b09e commit b45cc22

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,22 @@ var expected = JToken.Parse(@"{ ""value"" : 1.4 }");
5656
actual.Should().BeEquivalentTo(expected, options => options
5757
.Using<double>(d => d.Subject.Should().BeApproximately(d.Expectation, 0.1))
5858
.WhenTypeIs<double>());
59-
```
59+
```
60+
61+
Also, there is `WithoutStrictOrdering()` which allows you to compare JSON arrays while ignoring the order of their elements.
62+
This is useful when the sequence of items is not important for your test scenario. When applied, assertions like `BeEquivalentTo()` will
63+
succeed as long as the arrays contain the same elements, regardless of their order.
64+
65+
Example:
66+
67+
```c#
68+
using FluentAssertions;
69+
using FluentAssertions.Json;
70+
using Newtonsoft.Json.Linq;
71+
72+
...
73+
var actual = JToken.Parse(@"{ ""array"" : [1, 2, 3] }");
74+
var expected = JToken.Parse(@"{ ""array"" : [3, 2, 1] }");
75+
actual.Should().BeEquivalentTo(expected, options => options
76+
.WithoutStrictOrdering());
77+
```

0 commit comments

Comments
 (0)