Example #1
0
            public void PlaceRectanglesTightly(int width, int height)
            {
                var size = new Size(width, height);

                for (int i = 0; i < 500; ++i)
                {
                    BaseLayouter.PutNextRectangle(size);
                }
                var maxRadius = BaseLayouter.GetRectangles()
                                .Max(rectangle => GetDistanceToCenter(rectangle));
                var cloudMaxArea = maxRadius * maxRadius * Math.PI;
                var squareArea   = BaseLayouter.GetRectangles()
                                   .Select(rectangle => rectangle.Height * rectangle.Width)
                                   .Sum();
                var ratio = cloudMaxArea / squareArea;

                ratio.Should().BeLessThan(5);
            }