summaryrefslogtreecommitdiff
path: root/Plugins/MonoGame.Extended/tests/MonoGame.Extended.Tests/Serialization/RectangleFJsonConverterTest.cs
blob: 96f9c4f2566b98b1a33e4d8eaadda145da1b887a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System.IO;
using System.Text.Json;
using MonoGame.Extended.Serialization;
using Xunit;

namespace MonoGame.Extended.Tests.Serialization;

public class RectangleFJsonConverterTest
{

    public class TestContent
    {
        public RectangleF Box { get; set; }
    }

    [Fact]
    public void ConstructorTest()
    {
        var jsonData = @"
{
    ""box"": ""1 1 10 10""
}
";
        var options = new JsonSerializerOptions
        {
            PropertyNameCaseInsensitive = true
        };
        options.Converters.Add(new RectangleFJsonConverter());
        var content = JsonSerializer.Deserialize<TestContent>(jsonData, options);

        Assert.Equal(1, content.Box.Left);
        Assert.Equal(1, content.Box.Top);
        Assert.Equal(10, content.Box.Width);
        Assert.Equal(10, content.Box.Height);
    }
}