From acea7b2e728787a0d83bbf83c8c1f042d2c32e7e Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Mon, 3 Jun 2024 10:15:45 +0800 Subject: + plugins project --- .../Serialization/RectangleFJsonConverterTest.cs | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Plugins/MonoGame.Extended/tests/MonoGame.Extended.Tests/Serialization/RectangleFJsonConverterTest.cs (limited to 'Plugins/MonoGame.Extended/tests/MonoGame.Extended.Tests/Serialization/RectangleFJsonConverterTest.cs') diff --git a/Plugins/MonoGame.Extended/tests/MonoGame.Extended.Tests/Serialization/RectangleFJsonConverterTest.cs b/Plugins/MonoGame.Extended/tests/MonoGame.Extended.Tests/Serialization/RectangleFJsonConverterTest.cs new file mode 100644 index 0000000..96f9c4f --- /dev/null +++ b/Plugins/MonoGame.Extended/tests/MonoGame.Extended.Tests/Serialization/RectangleFJsonConverterTest.cs @@ -0,0 +1,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(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); + } +} -- cgit v1.1-26-g67d0