You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.0 KiB
37 lines
1.0 KiB
3 years ago
|
using System;
|
||
4 years ago
|
using System.Text.Json;
|
||
3 years ago
|
using Jellyfin.Extensions.Json.Converters;
|
||
4 years ago
|
using Xunit;
|
||
|
|
||
3 years ago
|
namespace Jellyfin.Extensions.Tests.Json.Converters
|
||
4 years ago
|
{
|
||
|
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);
|
||
|
}
|
||
|
}
|
||
4 years ago
|
}
|