コード例 #1
0
    public void Deserialize_WhenGivenEmpty_ReturnsDefaults()
    {
        var test = TestJson.Deserialize("{}");

        Assert.NotNull(test);

        Assert.Null(test.name);
        Assert.Equal(0, test.age);
        Assert.Null(test.home);
    }
コード例 #2
0
    public void Deserialize_WhenGivenFilled_ReturnsExpected()
    {
        var test = TestJson.Deserialize(@"
{
    ""name"": ""john"",
    ""age"": 24,
    ""home"": {
        ""address"": ""123 house street""
    }
}"
                                        );

        Assert.NotNull(test);
        Assert.NotNull(test.home);

        Assert.Equal("john", test.name);
        Assert.Equal(24, test.age);
        Assert.Equal("123 house street", test.home.address);
    }