Files
pgsql-jellyfin/tests/Jellyfin.Extensions.Tests/Json/Converters/JsonBoolStringTests.cs
T
wjones dbeec2e9f0 Refactor and modernize JSON converter test code
Refactor test code in Jellyfin.Extensions.Tests for clarity and consistency:
- Use explicit object initializers and collection expressions
- Standardize field naming and use of this.
- Add/improve XML doc comments for test methods
- Use new(...) syntax for Guid/Version instantiation
- Convert file-scoped to block-scoped namespaces in key tests
- Nest test classes and use instance methods in enum tests
- Enable XML docs and suppress select warnings in csproj
- No changes to test or converter logic; style and maintainability only
2026-02-22 10:31:23 -05:00

42 lines
1.3 KiB
C#

// <copyright file="JsonBoolStringTests.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
namespace Jellyfin.Extensions.Tests.Json.Converters
{
using System.Text.Json;
using Jellyfin.Extensions.Json.Converters;
using Xunit;
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)
{
TestStruct s = JsonSerializer.Deserialize<TestStruct>(input, this._jsonOptions);
Assert.Equal(s.Value, output);
}
[Theory]
[InlineData(true, "true")]
[InlineData(false, "false")]
public void Serialize_Bool_Success(bool input, string output)
{
string value = JsonSerializer.Serialize(input, this._jsonOptions);
Assert.Equal(value, output);
}
private readonly record struct TestStruct(bool Value);
}
}