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

namespace YMhut.Box.Tests;

[TestClass]
public sealed class ToolboxLayoutTests
{
    [TestMethod]
    [DataRow(480, 1)]
    [DataRow(760, 2)]
    [DataRow(1120, 3)]
    [DataRow(1440, 4)]
    [DataRow(1720, 5)]
    [DataRow(2200, 6)]
    public void ToolboxLayoutUsesStableBreakpoints(double width, int expectedColumns)
    {
        var layout = ToolboxLayoutCalculator.Calculate(width);

        Assert.AreEqual(expectedColumns, layout.Columns);
        Assert.IsGreaterThanOrEqualTo(ToolboxLayoutCalculator.MinCardWidth, layout.CardWidth);
        Assert.IsLessThanOrEqualTo(ToolboxLayoutCalculator.MaxCardWidth, layout.CardWidth);
    }

    [TestMethod]
    public void ToolboxLayoutKeepsCategoryRailOutOfNarrowWidths()
    {
        Assert.IsFalse(ToolboxLayoutCalculator.Calculate(760).ShowCategoryRail);
        Assert.IsTrue(ToolboxLayoutCalculator.Calculate(1180).ShowCategoryRail);
    }

    [TestMethod]
    public void ToolboxLayoutHasSafeFallbackForUnknownWidth()
    {
        var layout = ToolboxLayoutCalculator.Calculate(0);

        Assert.AreEqual(3, layout.Columns);
        Assert.AreEqual(318, layout.CardWidth);
        Assert.IsTrue(layout.ShowCategoryRail);
    }
}
