Files
pgsql-jellyfin/tests/Jellyfin.Extensions.Tests/Json/Converters/JsonBoolNumberTests.cs
T
wjones e81c127514 Add JSON config, DB-backed library options, and docs
- Add JSON-based config loading with XML fallback for DB and library options
- Implement LibraryOptionsRepository with EF Core, migrations, and entity
- Update CollectionFolder to use DB-backed options with XML fallback/backfill
- Register repository in DI and initialize at startup
- Use EF execution strategy for transactional DB operations
- Suppress code analysis warnings in .csproj and test files
- Add DATABASE_MIGRATION.md, LIBRARY_OPTIONS_DB_DESIGN.md, and WEBSOCKET_AUTHENTICATION.md
- Add database.json.example and improve migration docs
- Add tests for JSON config loader and update test naming warnings
2026-04-30 12:25:24 -04:00

76 lines
2.5 KiB
C#

// <copyright file="JsonBoolNumberTests.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
#pragma warning disable CA1707 // Identifiers should not contain underscores - xUnit test naming convention
#pragma warning disable CA1062 // Validate arguments of public methods - FsCheck generates valid inputs
namespace Jellyfin.Extensions.Tests.Json.Converters
{
using System.Text.Json;
using FsCheck;
using FsCheck.Fluent;
using FsCheck.Xunit;
using Jellyfin.Extensions.Json.Converters;
using Xunit;
/// <summary>
/// Tests for the JsonBoolNumberConverter.
/// </summary>
public class JsonBoolNumberTests
{
private readonly JsonSerializerOptions _jsonOptions = new()
{
Converters =
{
new JsonBoolNumberConverter(),
},
};
/// <summary>
/// Tests deserialization of numbers to boolean.
/// </summary>
/// <param name="input">The input string.</param>
/// <param name="output">The expected output.</param>
[Theory]
[InlineData("1", true)]
[InlineData("0", false)]
[InlineData("2", true)]
[InlineData("true", true)]
[InlineData("false", false)]
public void Deserialize_Number_Valid_Success(string input, bool? output)
{
bool value = JsonSerializer.Deserialize<bool>(input, this._jsonOptions);
Assert.Equal(value, output);
}
/// <summary>
/// Tests serialization of boolean values.
/// </summary>
/// <param name="input">The input boolean.</param>
/// <param name="output">The expected output.</param>
[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);
}
/// <summary>
/// Property test that non-zero integers deserialize to true.
/// </summary>
/// <param name="input">The input non-zero integer.</param>
/// <returns>A property test result.</returns>
[Property]
public Property Deserialize_NonZeroInt_True(NonZeroInt input)
{
return JsonSerializer.Deserialize<bool>(input.ToString(), this._jsonOptions).ToProperty();
}
}
}
#pragma warning restore CA1707
#pragma warning restore CA1062