public void RectanglesIsNotCrossing() { var isCrossing = false; for (int i = 0; i < 50; i++) { var rect = cloudLayouter.PushNextRectangle(new Size(50, 25)); isCrossing = isCrossing || rect.IsCrossing(cloudLayouter.GetRectangles() .Where(r => !r.Equals(rect)) .ToList()); } Assert.False(isCrossing); }
public void Cloud_IsCompact() { for (int i = 0; i < 20; i++) { cloudLayouter.PushNextRectangle(new Size(10, 5)); } var oldSummDistToCenter = cloudLayouter.GetRectangles().Sum(r => { var x = cloudLayouter.Center.X - r.Location.X; var y = cloudLayouter.Center.Y - r.Location.Y; return(Math.Sqrt(x * x + y * y)); } ); cloudLayouter = new CircularCloudLayouter(cloudLayouter.Center); for (int i = 0; i < 20; i++) { cloudLayouter.PushNextRectangle(new Size(10, 5)); } var newSummDistToCenter = cloudLayouter.GetRectangles().Sum(r => { var x = cloudLayouter.Center.X - r.Location.X; var y = cloudLayouter.Center.Y - r.Location.Y; return(Math.Sqrt(x * x + y * y)); } ); Assert.GreaterOrEqual(oldSummDistToCenter, newSummDistToCenter); }