diff options
| author | Bond-009 <bond.009@outlook.com> | 2021-03-06 00:03:08 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-06 00:03:08 +0100 |
| commit | db2d1bca33768224f9f3a07d6965c097f6289441 (patch) | |
| tree | 2ef6db8072a4624fda1e526b9f8f4ced255bc98b /tests | |
| parent | 3741be51ec4b44f946bcdc3ad4f5232af0e2e929 (diff) | |
| parent | df1951cfe2baae539758b9592af1a16e51b69897 (diff) | |
Merge pull request #5382 from crobibero/json-version-converter
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/Jellyfin.Common.Tests/Json/JsonVersionConverterTests.cs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/Jellyfin.Common.Tests/Json/JsonVersionConverterTests.cs b/tests/Jellyfin.Common.Tests/Json/JsonVersionConverterTests.cs new file mode 100644 index 000000000..f2cefdbf8 --- /dev/null +++ b/tests/Jellyfin.Common.Tests/Json/JsonVersionConverterTests.cs @@ -0,0 +1,36 @@ +using System; +using System.Text.Json; +using MediaBrowser.Common.Json.Converters; +using Xunit; + +namespace Jellyfin.Common.Tests.Json +{ + public class JsonVersionConverterTests + { + private readonly JsonSerializerOptions _options; + + public JsonVersionConverterTests() + { + _options = new JsonSerializerOptions(); + _options.Converters.Add(new JsonVersionConverter()); + } + + [Fact] + public void Deserialize_Version_Success() + { + var input = "\"1.025.222\""; + var output = new Version(1, 25, 222); + var deserializedInput = JsonSerializer.Deserialize<Version>(input, _options); + Assert.Equal(output, deserializedInput); + } + + [Fact] + public void Serialize_Version_Success() + { + var input = new Version(1, 09, 59); + var output = "\"1.9.59\""; + var serializedInput = JsonSerializer.Serialize(input, _options); + Assert.Equal(output, serializedInput); + } + } +} |
