using Microsoft.VisualStudio.TestTools.UnitTesting;
using YMhut.Box.Core.Media;

namespace YMhut.Box.Tests;

[TestClass]
public sealed class MediaVolumeModelTests
{
    [TestMethod]
    public void FromPercentClampsAndMapsOutputModes()
    {
        var silent = MediaVolumeModel.FromPercent(-5);
        Assert.AreEqual(0, silent.Percent);
        Assert.AreEqual(0, silent.PlatformVolume, 0.001);
        Assert.AreEqual(0, silent.AudioGain, 0.001);
        Assert.AreEqual(MediaVolumeOutputMode.Silent, silent.Mode);

        var normal = MediaVolumeModel.FromPercent(80);
        Assert.AreEqual(80, normal.Percent);
        Assert.AreEqual(0.8, normal.PlatformVolume, 0.001);
        Assert.AreEqual(0.8, normal.AudioGain, 0.001);
        Assert.AreEqual(MediaVolumeOutputMode.Normal, normal.Mode);

        var boosted = MediaVolumeModel.FromPercent(120);
        Assert.AreEqual(120, boosted.Percent);
        Assert.AreEqual(1.0, boosted.PlatformVolume, 0.001);
        Assert.AreEqual(1.2, boosted.AudioGain, 0.001);
        Assert.AreEqual(MediaVolumeOutputMode.Boosted, boosted.Mode);
    }

    [TestMethod]
    public void FormatPercentNamesMutedAndBoostedStates()
    {
        Assert.AreEqual("0%（静音）", MediaVolumeModel.FormatPercent(0, "zh-CN"));
        Assert.AreEqual("120%（增强音量）", MediaVolumeModel.FormatPercent(120, "zh-CN"));
        Assert.AreEqual("0% (Muted)", MediaVolumeModel.FormatPercent(0, "en-US"));
        Assert.AreEqual("120% (Boosted)", MediaVolumeModel.FormatPercent(120, "en-US"));
    }
}
