using QuestPDF.Infrastructure; namespace QuestPDF.LayoutTests.TestEngine; internal sealed class LayoutTestResult { public Size PageSize { get; set; } public DocumentLayout ActualLayout { get; set; } public DocumentLayout ExpectedLayout { get; set; } public sealed class DocumentLayout { public ICollection Pages { get; set; } = new List(); public bool GeneratesInfiniteLayout { get; set; } } public sealed class PageLayout { public Size RequiredArea { get; set; } public ICollection Mocks { get; set; } } public sealed class MockLayoutPosition { public string MockId { get; set; } public Position Position { get; set; } public Size Size { get; set; } } } internal static class LayoutTestResultHelpers { public static IEnumerable<(LayoutTestResult.MockLayoutPosition Below, LayoutTestResult.MockLayoutPosition Above)> GetOverlappingItems(this ICollection items) { for (var i = 0; i < items.Count; i++) { for (var j = i + 1; j < items.Count; j++) { var beforeChild = items.ElementAt(i); var afterChild = items.ElementAt(j); var beforeBoundingBox = BoundingBox.From(beforeChild.Position, beforeChild.Size); var afterBoundingBox = BoundingBox.From(afterChild.Position, afterChild.Size); var intersection = BoundingBoxExtensions.Intersection(beforeBoundingBox, afterBoundingBox); if (intersection == null) continue; yield return (beforeChild, afterChild); } } } }