aboutsummaryrefslogtreecommitdiff
path: root/tests/Jellyfin.Extensions.Tests/Json
diff options
context:
space:
mode:
authorBond_009 <bond.009@outlook.com>2023-02-01 14:58:04 +0100
committerBond_009 <bond.009@outlook.com>2023-02-01 14:58:04 +0100
commit65d605b17dfc978ebc089b7500a5aacd8fcd863f (patch)
tree45b9b6716ba7ff27b302e04925b2952005d510b3 /tests/Jellyfin.Extensions.Tests/Json
parent992b460912f3100f126bc4db0fe042fd4aefee7c (diff)
Improve ffprobe json parsing and don't log error for Codec Type attachment
Diffstat (limited to 'tests/Jellyfin.Extensions.Tests/Json')
-rw-r--r--tests/Jellyfin.Extensions.Tests/Json/Converters/JsonBoolStringTests.cs37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/Jellyfin.Extensions.Tests/Json/Converters/JsonBoolStringTests.cs b/tests/Jellyfin.Extensions.Tests/Json/Converters/JsonBoolStringTests.cs
new file mode 100644
index 000000000..be256da2e
--- /dev/null
+++ b/tests/Jellyfin.Extensions.Tests/Json/Converters/JsonBoolStringTests.cs
@@ -0,0 +1,37 @@
+using System.Text.Json;
+using Jellyfin.Extensions.Json.Converters;
+using Xunit;
+
+namespace Jellyfin.Extensions.Tests.Json.Converters
+{
+ public class JsonBoolStringTests
+ {
+ private readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions()
+ {
+ Converters =
+ {
+ new JsonBoolStringConverter()
+ }
+ };
+
+ [Theory]
+ [InlineData(@"{ ""Value"": ""true"" }", true)]
+ [InlineData(@"{ ""Value"": ""false"" }", false)]
+ public void Deserialize_String_Valid_Success(string input, bool output)
+ {
+ var s = JsonSerializer.Deserialize<TestStruct>(input, _jsonOptions);
+ Assert.Equal(s.Value, output);
+ }
+
+ [Theory]
+ [InlineData(true, "true")]
+ [InlineData(false, "false")]
+ public void Serialize_Bool_Success(bool input, string output)
+ {
+ var value = JsonSerializer.Serialize(input, _jsonOptions);
+ Assert.Equal(value, output);
+ }
+
+ private readonly record struct TestStruct(bool Value);
+ }
+}