Skip to content

Commit

Permalink
added array tests for tuple (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilchert authored Jan 15, 2024
1 parent 03ff51b commit 565b05e
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,23 @@ public void WriteJsonFromDto<T>(T value, string expected)
Assert.True(isEquals, "Json not equal.");
}

[Theory]
[MemberData(nameof(Data))]
public void ReadJsonFromArray<T>(T expected, string json)
{
var actual = JsonSerializer.Deserialize<T[]>($"[{json}]", _options);
Assert.Equivalent((T[])[expected], actual);
}

[Theory]
[MemberData(nameof(Data))]
public void WriteJsonFromArray<T>(T value, string expected)
{
var actual = JsonSerializer.Serialize<T[]>([value], _options);
var isEquals = JsonNode.DeepEquals(JsonNode.Parse($"[{expected}]"), JsonNode.Parse(actual));
Assert.True(isEquals, "Json not equal.");
}

private class EmptyDto();

private class Dto<T>
Expand Down

0 comments on commit 565b05e

Please sign in to comment.