mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-24 12:06:37 +00:00
* Converted to use `System.Text.Json` * Remove Newtonsoft.Json Dependency Newtonsoft.Json dependency has been removed in favor of System.Text.Json * Treat MGFXO file as binary
37 lines
831 B
C#
37 lines
831 B
C#
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);
|
|
}
|
|
}
|