Exemple #1
0
        private static void GenerateLayoutAndSaveToFile(string filePath, Point center, Size canvasSize, int rectCount)
        {
            var layouter         = new CircularCloudLayouter(center);
            var placedRectangles = RandomEntitiesFabric.GetRandomLayout(layouter, rectCount);

            using (var painter = new CloudPainter(canvasSize))
            {
                painter.PaintRectangles(placedRectangles)
                .SaveToFile(filePath);
            }
        }
        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);
        }
        public void BeAble_ToPlaceSeveralRectangles(int count)
        {
            Action act = () => currentLayout = RandomEntitiesFabric.GetRandomLayout(layouter, count).ToList();

            act.ShouldNotThrow();
        }
 public void SetUp()
 {
     layouter      = RandomEntitiesFabric.GetRandomLayouter(CanvasSideLength);
     currentLayout = new List <Rectangle>();
 }