public void LayOutRectangles_Tightly(double ratioOfAreas, int numOfRectangles)
        {
            layouter = FillUpLayout(layouter, numOfRectangles);
            var center           = new Point(screenBounds.Width / 2, screenBounds.Height / 2);
            var radius           = layouter.Layout().Select(rectangle => GetMaxDistance(rectangle, center)).Max();
            var areaOfRectangles = layouter.Layout().Sum(r => (double)r.Height * r.Width);
            var areaOfCircle     = Math.PI * Math.Pow(radius, 2);

            areaOfRectangles.Should().BeGreaterThan(areaOfCircle * ratioOfAreas);
        }
        public void LayOutRectangles_WithoutIntersection(int numOfRectangles)
        {
            layouter = FillUpLayout(layouter, numOfRectangles);
            var layout = layouter.Layout();

            foreach (var rectangleA in layout)
            {
                foreach (var rectangleB in layout)
                {
                    if (rectangleA != rectangleB)
                    {
                        rectangleA.IntersectsWith(rectangleB).Should().Be(false);
                    }
                }
            }
        }
 public void TearDown()
 {
     if (TestContext.CurrentContext.Result.FailCount > 0)
     {
         var testName = TestContext.CurrentContext.Test.Name;
         var bitmap   = new Bitmap(screenBounds.Width, screenBounds.Height);
         var drawer   = Graphics.FromImage(bitmap);
         foreach (var r in layouter.Layout())
         {
             drawer.DrawRectangle(new Pen(Color.Black, 1), r);
         }
         var path = Path.Combine(Path.GetTempPath(), testName + ".png");
         bitmap.Save(path);
         TestContext.WriteLine("Tag cloud visualization saved to file " + path);
     }
 }
 public void AddingRectanglesToLayout(int numOfRectangles)
 {
     layouter = FillUpLayout(layouter, numOfRectangles);
     layouter.Layout().Count.Should().Be(numOfRectangles);
 }