Skip to content

Commit

Permalink
chore: add json roundtrip test with JsonUtility
Browse files Browse the repository at this point in the history
  • Loading branch information
filzrev committed Sep 26, 2024
1 parent cf7bf6c commit 3b3bd35
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/docfx.Tests/SerializationTests/JsonSerializationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ protected void ValidateJsonRoundTrip<T>(T model)
systemTextJsonModel.Should().BeEquivalentTo(model, assertionOptions);
newtonsoftJsonModel.Should().BeEquivalentTo(model, assertionOptions);

// 3. Validate JsonUtility roundtrip result.
json = JsonUtility.Serialize(model);
var result = JsonUtility.Deserialize<T>(new StringReader(json));
result.Should().BeEquivalentTo(model, assertionOptions);

// Helper local function
static EquivalencyAssertionOptions<T> assertionOptions(EquivalencyAssertionOptions<T> opt)
{
Expand Down

0 comments on commit 3b3bd35

Please sign in to comment.