コード例 #1
0
        public void PushNextRectangle_PushFirstRectangle()
        {
            var size          = new Size(10, 10);
            var nextRectangle = cloudLayouter.PushNextRectangle(size);

            Assert.AreEqual(cloudLayouter.Center, nextRectangle.GetCenter());
        }
コード例 #2
0
        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);
        }