예제 #1
0
        public void PutNextRectangle_WithoutIntersectionsWithPastRectangles()
        {
            var firstRectangleSize  = new Size(100, 100);
            var secondRectangleSize = new Size(100, 100);

            var firstRectangleLocation = rectangleLayouter
                                         .PutNextRectangle(firstRectangleSize);
            var secondRectangleLocation = rectangleLayouter
                                          .PutNextRectangle(secondRectangleSize);

            firstRectangleLocation
            .IntersectsWith(secondRectangleLocation)
            .Should().BeFalse();
        }
예제 #2
0
        public void PutNextRectangle_1000RandomSizes_ReturnedRectanglesShouldNotIntersect()
        {
            var rectangles = new List <Rectangle>();

            for (var i = 0; i < 100; i++)
            {
                rectangles.Add(cloud.PutNextRectangle(new Size(random.Next(1, 100), random.Next(1, 100))));
            }
            rectangles.Any(rectangle => rectangles.Any(otherRectangle =>
                                                       rectangle != otherRectangle && rectangle.IntersectsWith(otherRectangle))).Should()
            .BeFalse("some rectangles intersect");
        }
예제 #3
0
        public void PutNextRectangle_InCenter_When(int centerX, int centerY,
                                                   int rectangleWidth, int rectangleHeight)
        {
            var center = new Point(centerX, centerY);

            rectangleLayouter = new RectangleLayouter(center,
                                                      new SpiralTrack(center, trackStep));

            var rectangleSize   = new Size(rectangleWidth, rectangleHeight);
            var leftTopLocation = new Point(
                (int)Math.Ceiling(center.X - rectangleSize.Width / 2d),
                (int)Math.Ceiling(center.Y - rectangleSize.Height / 2d)
                );
            var expectedLocation = new Rectangle(leftTopLocation, rectangleSize);

            var rectangleLocation = rectangleLayouter.PutNextRectangle(rectangleSize);

            rectangleLocation.Should().Be(expectedLocation);
        }