using LehrerApp.Templating; using Xunit; namespace LehrerApp.Templating.Tests; public sealed class ReportDrawingTests { [Fact] public void LangeTexte_WerdenNurZwischenZeilenAufSeitenVerteilt() { var drawing = ReportTextDrawing.Build("Überschrift", [new string('W', 300)], 55, 1, 17); var lines = drawing.Commands.OfType().ToList(); Assert.True(drawing.ContentHeight > 17); Assert.All(lines, line => Assert.True(line.Y % 17 + line.Height <= 17.001f)); Assert.Equal(new string('W', 300), string.Concat(lines.Skip(1).Select(line => line.Text))); } [Fact] public void FesteBox_MeldetUeberlaufStattAbzuschneiden() { Assert.Throws(() => ReportTextDrawing.Build("Titel", [new string('W', 300)], 55, 1, 17, true)); } [Fact] public void TexteUndGraphen_BeachtenDieMassEinheit() { var scale = 72f / 25.4f; var mm = ReportTextDrawing.Build("Titel", ["Eine Beobachtung zum Lernfortschritt."], 170); var pt = ReportTextDrawing.Build("Titel", ["Eine Beobachtung zum Lernfortschritt."], 170 * scale, scale, 240 * scale); Assert.Equal(mm.ContentHeight * scale, pt.ContentHeight, 2); var from = new DateOnly(2026, 10, 1); ReportChartSeries[] series = [new("Qualität", "#123456", [new(from, 1), new(from.AddDays(1), -1)])]; var chartMm = ParticipationReportDrawing.Build(series, from, from.AddDays(1)); var chartPt = ParticipationReportDrawing.Build(series, from, from.AddDays(1), 170 * scale, scale); Assert.Equal(chartMm.ContentHeight * scale, chartPt.ContentHeight, 2); } }