aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorClaus Vium <cvium@users.noreply.github.com>2020-12-08 08:58:01 +0100
committerGitHub <noreply@github.com>2020-12-08 08:58:01 +0100
commit0aad17554c737404aaf9492d4cb16eee2ccbd4e7 (patch)
tree66e94129f2d7554e3b6934f57a60879efc6507c4 /tests
parent0d5f651ae9c38b2fcda7fb0f6d0051bc6a18586e (diff)
parent6e9837844738de7bc55dae9994538535e62ed888 (diff)
Merge pull request #4715 from crobibero/hdhr-json-bool
Add number to bool json converter
Diffstat (limited to 'tests')
-rw-r--r--tests/Jellyfin.Common.Tests/Json/JsonBoolNumberTests.cs23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/Jellyfin.Common.Tests/Json/JsonBoolNumberTests.cs b/tests/Jellyfin.Common.Tests/Json/JsonBoolNumberTests.cs
new file mode 100644
index 000000000..3779e2d0a
--- /dev/null
+++ b/tests/Jellyfin.Common.Tests/Json/JsonBoolNumberTests.cs
@@ -0,0 +1,23 @@
+using System.Text.Json;
+using MediaBrowser.Common.Json.Converters;
+using Xunit;
+
+namespace Jellyfin.Common.Tests.Json
+{
+ public static class JsonBoolNumberTests
+ {
+ [Theory]
+ [InlineData("1", true)]
+ [InlineData("0", false)]
+ [InlineData("2", true)]
+ [InlineData("true", true)]
+ [InlineData("false", false)]
+ public static void Deserialize_Number_Valid_Success(string input, bool? output)
+ {
+ var options = new JsonSerializerOptions();
+ options.Converters.Add(new JsonBoolNumberConverter());
+ var value = JsonSerializer.Deserialize<bool>(input, options);
+ Assert.Equal(value, output);
+ }
+ }
+} \ No newline at end of file