示例#1
0
 public void PutRectanglesOnLayout_WithoutIntersection()
 {
     rectangles = CloudLayouterUtilities.GenerateRandomLayout(
         center, rnd.Next(2, 25), minWidth, maxWidth, minHeight, maxHeight);
     foreach (var rectangle in rectangles)
     {
         rectangles
         .Any(rect => rect.IntersectsWith(rectangle) && rect != rectangle)
         .Should()
         .BeFalse("rectangles should not intersect!");
     }
 }
示例#2
0
        public void PutRectangles_DenselyAroundCenter(int x, int y)
        {
            center   = new Point(x, y);
            layouter = new CircularCloudLayouter(center);

            rectangles = CloudLayouterUtilities.GenerateRandomLayout(
                center, rnd.Next(25, 50), minWidth, maxWidth, minHeight, maxHeight);
            var totalMass = rectangles.Select(rect => rect.Width * rect.Height).Sum();

            var maxSquaredDistance = center.GetMaxSquaredDistanceTo(rectangles);
            var circleSize         = Math.PI * maxSquaredDistance;
            var emptyArea          = circleSize - totalMass;

            emptyArea.Should().NotBeInRange(circleSize / 2, double.MaxValue,
                                            "more than half of the minimum circular area containing all" +
                                            "of the rectangles should not be empty");
        }