// <copyright file="JsonVersionConverterTests.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>

namespace Jellyfin.Extensions.Tests.Json.Converters
{
    using System;
    using System.Text.Json;
    using Jellyfin.Extensions.Json.Converters;
    using Xunit;

    public class JsonVersionConverterTests
    {
        private readonly JsonSerializerOptions _options;

        public JsonVersionConverterTests()
        {
            this._options = new JsonSerializerOptions();
            this._options.Converters.Add(new JsonVersionConverter());
        }

        [Fact]
        public void Deserialize_Version_Success()
        {
            string input = "\"1.025.222\"";
            Version output = new(1, 25, 222);
            Version? deserializedInput = JsonSerializer.Deserialize<Version>(input, this._options);
            Assert.Equal(output, deserializedInput);
        }

        [Fact]
        public void Serialize_Version_Success()
        {
            Version input = new(1, 09, 59);
            string output = "\"1.9.59\"";
            string serializedInput = JsonSerializer.Serialize(input, this._options);
            Assert.Equal(output, serializedInput);
        }
    }
}
