aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorClaus Vium <cvium@users.noreply.github.com>2020-12-08 08:58:01 +0100
committerJoshua M. Boniface <joshua@boniface.me>2020-12-13 20:34:32 -0500
commit2e5333c1d45b3dcebabfb5bfa27b2b250b10667c (patch)
treeb54cb522f2c05e0f28172d56c1e72a3fb91de189 /tests
parente8e1bbffd954dfb65767212ad55f6e312ad42ff4 (diff)
Merge pull request #4715 from crobibero/hdhr-json-bool
Add number to bool json converter (cherry picked from commit 0aad17554c737404aaf9492d4cb16eee2ccbd4e7) Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
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