public void NotPlace_IntersectingRectangles() { currentLayout = RandomEntitiesFabric.GetRandomLayout(layouter, RandomEntitiesFabric.GetRandomInt(10, 30)) .ToList(); var intersections = currentLayout.Select((rect, index) => new { rect, index }) .SelectMany(r => currentLayout.Skip(r.index + 1), (r1, r2) => r1.rect.IntersectsWith(r2)); intersections.Any(b => b) .Should() .BeFalse(); }
public void GenerateDenseLayout() { const double margin = 0.5; currentLayout = RandomEntitiesFabric.GetRandomLayout(layouter, RandomEntitiesFabric.GetRandomInt(40, 70)) .ToList(); var radius = GetLayoutRadius(currentLayout); var coveringCircleArea = radius * radius * Math.PI; var actualArea = currentLayout.Select(r => r.Area()) .Sum(); Math.Min(coveringCircleArea / actualArea, actualArea / coveringCircleArea) .Should() .BeGreaterOrEqualTo(margin); }