JsonBoolNumberTests.cs 714 B

1234567891011121314151617181920212223
  1. using System.Text.Json;
  2. using Jellyfin.Common.Tests.Models;
  3. using Xunit;
  4. namespace Jellyfin.Common.Tests.Json
  5. {
  6. public static class JsonBoolNumberTests
  7. {
  8. [Theory]
  9. [InlineData("1", true)]
  10. [InlineData("0", false)]
  11. [InlineData("2", true)]
  12. [InlineData("true", true)]
  13. [InlineData("false", false)]
  14. public static void Deserialize_Number_Valid_Success(string input, bool? output)
  15. {
  16. var inputJson = $"{{ \"Value\": {input} }}";
  17. var options = new JsonSerializerOptions();
  18. var value = JsonSerializer.Deserialize<BoolTypeModel>(inputJson, options);
  19. Assert.Equal(value?.Value, output);
  20. }
  21. }
  22. }