// <copyright file="JsonStringConverterTests.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 JsonStringConverterTests
    {
        private readonly JsonSerializerOptions _jsonSerializerOptions = new()
        {
            Converters =
            {
                new JsonStringConverter(),
            },
        };

        [Theory]
        [InlineData("\"test\"", "test")]
        [InlineData("123", "123")]
        [InlineData("123.45", "123.45")]
        [InlineData("true", "true")]
        [InlineData("false", "false")]
        public void Deserialize_String_Valid_Success(string input, string output)
        {
            string? deserialized = JsonSerializer.Deserialize<string>(input, this._jsonSerializerOptions);
            Assert.Equal(deserialized, output);
        }

        [Fact]
        public void Deserialize_Int32asInt32_Valid_Success()
        {
            const string? input = "123";
            const int output = 123;
            int deserialized = JsonSerializer.Deserialize<int>(input, this._jsonSerializerOptions);
            Assert.Equal(output, deserialized);
        }
    }
}
