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.
jellyfin/tests/Jellyfin.Extensions.Tests/Json/Converters/JsonBoolStringTests.cs

38 lines
1.1 KiB

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);
}
}