RectangleFJsonConverterTest.cs 806 B

12345678910111213141516171819202122232425262728293031323334
  1. using System.Text.Json;
  2. using MonoGame.Extended.Serialization.Json;
  3. namespace MonoGame.Extended.Tests.Serialization;
  4. public class RectangleFJsonConverterTest
  5. {
  6. public class TestContent
  7. {
  8. public RectangleF Box { get; set; }
  9. }
  10. [Fact]
  11. public void ConstructorTest()
  12. {
  13. var jsonData = @"
  14. {
  15. ""box"": ""1 1 10 10""
  16. }
  17. ";
  18. var options = new JsonSerializerOptions
  19. {
  20. PropertyNameCaseInsensitive = true
  21. };
  22. options.Converters.Add(new RectangleFJsonConverter());
  23. var content = JsonSerializer.Deserialize<TestContent>(jsonData, options);
  24. Assert.Equal(1, content.Box.Left);
  25. Assert.Equal(1, content.Box.Top);
  26. Assert.Equal(10, content.Box.Width);
  27. Assert.Equal(10, content.Box.Height);
  28. }
  29. }