diff options
| author | Shadowghost <Ghost_of_Stone@web.de> | 2023-02-15 22:40:07 +0100 |
|---|---|---|
| committer | Shadowghost <Ghost_of_Stone@web.de> | 2023-02-15 22:40:07 +0100 |
| commit | 3a91c37283eb633e7e55df78b8017a5a492923b6 (patch) | |
| tree | 4e22db9a5234c63370195992a28c64891d7a6cc1 /tests/Jellyfin.Extensions.Tests/Json/Converters/JsonBoolStringTests.cs | |
| parent | 4eba16c6726564b159e395e188ec89f69d990e52 (diff) | |
| parent | 3fe64f69b747f39a6505e4fad1bbd6eaf63cecc4 (diff) | |
Merge branch 'master' into network-rewrite
Diffstat (limited to 'tests/Jellyfin.Extensions.Tests/Json/Converters/JsonBoolStringTests.cs')
| -rw-r--r-- | tests/Jellyfin.Extensions.Tests/Json/Converters/JsonBoolStringTests.cs | 37 |
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); + } +} |
