Simplify converter

This commit is contained in:
crobibero
2020-12-07 14:58:27 -07:00
parent 66a1880a58
commit 6e98378447
4 changed files with 6 additions and 25 deletions

View File

@@ -1,5 +1,5 @@
using System.Text.Json;
using Jellyfin.Common.Tests.Models;
using MediaBrowser.Common.Json.Converters;
using Xunit;
namespace Jellyfin.Common.Tests.Json
@@ -14,10 +14,10 @@ namespace Jellyfin.Common.Tests.Json
[InlineData("false", false)]
public static void Deserialize_Number_Valid_Success(string input, bool? output)
{
var inputJson = $"{{ \"Value\": {input} }}";
var options = new JsonSerializerOptions();
var value = JsonSerializer.Deserialize<BoolTypeModel>(inputJson, options);
Assert.Equal(value?.Value, output);
options.Converters.Add(new JsonBoolNumberConverter());
var value = JsonSerializer.Deserialize<bool>(input, options);
Assert.Equal(value, output);
}
}
}

View File

@@ -1,17 +0,0 @@
using System.Text.Json.Serialization;
using MediaBrowser.Common.Json.Converters;
namespace Jellyfin.Common.Tests.Models
{
/// <summary>
/// The bool type model.
/// </summary>
public class BoolTypeModel
{
/// <summary>
/// Gets or sets a value indicating whether the value is true or false.
/// </summary>
[JsonConverter(typeof(JsonBoolNumberConverter))]
public bool Value { get; set; }
}
}