|
5 | 5 | using System.Globalization; |
6 | 6 | using System.IO; |
7 | 7 | using System.Linq; |
| 8 | +using System.Text.Json; |
8 | 9 | using System.Text.Json.Nodes; |
9 | 10 | using FluentAssertions; |
10 | 11 | using Microsoft.OpenApi.Models; |
@@ -72,20 +73,20 @@ public void ParseObjectAsAnyShouldSucceed() |
72 | 73 | }; |
73 | 74 |
|
74 | 75 | anyMap = OpenApiAnyConverter.GetSpecificOpenApiAny(anyMap, schema); |
75 | | - |
| 76 | + var expected = new JsonObject |
| 77 | + { |
| 78 | + ["aString"] = "fooBar", |
| 79 | + ["aInteger"] = 10, |
| 80 | + ["aDouble"] = 2.34, |
| 81 | + ["aDateTime"] = DateTimeOffset.Parse("2017-01-01", CultureInfo.InvariantCulture), |
| 82 | + ["aDate"] = DateTimeOffset.Parse("2017-01-02", CultureInfo.InvariantCulture).Date |
| 83 | + }; |
| 84 | + |
76 | 85 | diagnostic.Errors.Should().BeEmpty(); |
77 | | - anyMap.Should().BeEquivalentTo( |
78 | | - new JsonObject |
79 | | - { |
80 | | - ["aString"] = "fooBar", |
81 | | - ["aInteger"] = 10, |
82 | | - ["aDouble"] = 2.34, |
83 | | - ["aDateTime"] = DateTimeOffset.Parse("2017-01-01", CultureInfo.InvariantCulture), |
84 | | - ["aDate"] = DateTimeOffset.Parse("2017-01-02", CultureInfo.InvariantCulture).Date |
85 | | - }); |
| 86 | + anyMap.Should().BeEquivalentTo(expected, options => options.IgnoringCyclicReferences()); |
86 | 87 | } |
87 | 88 |
|
88 | | - |
| 89 | + |
89 | 90 | [Fact] |
90 | 91 | public void ParseNestedObjectAsAnyShouldSucceed() |
91 | 92 | { |
@@ -261,7 +262,7 @@ public void ParseNestedObjectAsAnyShouldSucceed() |
261 | 262 | }, |
262 | 263 | ["aDouble"] = 2.34, |
263 | 264 | ["aDateTime"] = DateTimeOffset.Parse("2017-01-01", CultureInfo.InvariantCulture) |
264 | | - }); |
| 265 | + }, options => options.IgnoringCyclicReferences()); |
265 | 266 | } |
266 | 267 |
|
267 | 268 |
|
@@ -416,7 +417,7 @@ public void ParseNestedObjectAsAnyWithPartialSchemaShouldSucceed() |
416 | 417 | }, |
417 | 418 | ["aDouble"] = 2.34, |
418 | 419 | ["aDateTime"] = DateTimeOffset.Parse("2017-01-01", CultureInfo.InvariantCulture) |
419 | | - }); |
| 420 | + }, options => options.IgnoringCyclicReferences()); |
420 | 421 | } |
421 | 422 |
|
422 | 423 | [Fact] |
@@ -508,7 +509,7 @@ public void ParseNestedObjectAsAnyWithoutUsingSchemaShouldSucceed() |
508 | 509 | }, |
509 | 510 | ["aDouble"] = 2.34, |
510 | 511 | ["aDateTime"] = DateTimeOffset.Parse("2017-01-01", CultureInfo.InvariantCulture) |
511 | | - }); |
| 512 | + }, options => options.IgnoringCyclicReferences()); |
512 | 513 | } |
513 | 514 | } |
514 | 515 | } |
0 commit comments