using Xunit;
using ytLive.Models;
namespace ytLive.Tests;
/// Two creator rulings live here: the strip and the social bar own OPPOSITE edges (coupled,
/// resolved from what is visible), and a strip that does not fit shrinks to a legibility floor and
/// then wraps — it never scrolls.
public class ScoreboardLayoutTests
{
[Fact]
public void Bars_never_share_an_edge_and_an_overlong_strip_shrinks_then_wraps()
{
// Both visible: opposite edges, whatever the scoreboard asked for.
Assert.Equal((BarEdge.Top, BarEdge.Bottom),
ScoreboardLayout.ResolveEdges(true, BarEdge.Top, true, BarEdge.Top));
Assert.Equal((BarEdge.Bottom, BarEdge.Top),
ScoreboardLayout.ResolveEdges(true, BarEdge.Bottom, true, BarEdge.Bottom));
// Social bar hidden: the scoreboard keeps its own preference.
Assert.Equal((BarEdge.Top, BarEdge.Bottom),
ScoreboardLayout.ResolveEdges(false, BarEdge.Top, true, BarEdge.Bottom));
// Scoreboard hidden: the social bar is free.
Assert.Equal((BarEdge.Bottom, BarEdge.Top),
ScoreboardLayout.ResolveEdges(true, BarEdge.Bottom, false, BarEdge.Top));
// Fits at full size.
var fit = ScoreboardLayout.FitLine(new[] { 200.0, 200.0, 200.0 }, 40, 1920);
Assert.Equal(ScoreboardLayout.MaxFontSize, fit.FontSize);
Assert.Equal(1, fit.LineCount);
Assert.False(fit.Shrunk);
// Too wide for full size, but a shrink keeps it on one line.
fit = ScoreboardLayout.FitLine(new[] { 400.0, 400.0, 400.0 }, 40, 900);
Assert.True(fit.FontSize < ScoreboardLayout.MaxFontSize);
Assert.True(fit.FontSize >= ScoreboardLayout.FloorFontSize);
Assert.Equal(1, fit.LineCount);
Assert.True(fit.Shrunk);
// Far too wide even at the floor: two lines, never a scroll.
fit = ScoreboardLayout.FitLine(new[] { 600.0, 600.0, 600.0, 600.0 }, 40, 700);
Assert.Equal(ScoreboardLayout.FloorFontSize, fit.FontSize);
Assert.True(fit.LineCount > 1);
Assert.True(fit.Wrapped);
// Nothing enabled: no crash, no lines invented.
Assert.Equal(1, ScoreboardLayout.FitLine(System.Array.Empty(), 40, 1920).LineCount);
}
}