Ejemplo n.º 1
0
            public void PutFirstRectangleInCenter()
            {
                var rectangle = BaseLayouter.PutNextRectangle(BasicSize);

                rectangle.X.Should().Be(BasicCenter.X - BasicSize.Width / 2);
                rectangle.Y.Should().Be(BasicCenter.Y - BasicSize.Height / 2);
            }
Ejemplo n.º 2
0
            public void ThrowArgumentException_OnNegativeOrZeroRectangleSize(int height, int width)
            {
                var    size         = new Size(height, width);
                Action getRectangle = () => BaseLayouter.PutNextRectangle(size);

                getRectangle.Should().Throw <ArgumentException>().WithMessage("Invalid size");
            }
Ejemplo n.º 3
0
            public void PlaceRectanglesFast()
            {
                var size = new Size(1, 1);

                for (int i = 0; i < 10000; ++i)
                {
                    BaseLayouter.PutNextRectangle(size);
                }
            }
Ejemplo n.º 4
0
            public void PlaceSameRectanglesWithoutIntersection(int height, int width)
            {
                var size       = new Size(height, width);
                var rectangles = new List <Rectangle>();

                for (int i = 0; i < 10; ++i)
                {
                    rectangles.Add(BaseLayouter.PutNextRectangle(size));
                }
                AreIntersecting(rectangles).Should().BeFalse();
            }
Ejemplo n.º 5
0
            public void PlaceDifferentRectanglesWithoutIntersection()
            {
                var rectangles = new List <Rectangle>();
                var size       = new Size(2, 1);

                for (int i = 0; i < 10; ++i)
                {
                    rectangles.Add(BaseLayouter.PutNextRectangle(size));
                    size.Height++;
                    size.Width++;
                }
                AreIntersecting(rectangles).Should().BeFalse();
            }
Ejemplo n.º 6
0
            public void PlaceRectanglesTightly(int width, int height)
            {
                var size = new Size(width, height);

                for (int i = 0; i < 500; ++i)
                {
                    BaseLayouter.PutNextRectangle(size);
                }
                var maxRadius = BaseLayouter.GetRectangles()
                                .Max(rectangle => GetDistanceToCenter(rectangle));
                var cloudMaxArea = maxRadius * maxRadius * Math.PI;
                var squareArea   = BaseLayouter.GetRectangles()
                                   .Select(rectangle => rectangle.Height * rectangle.Width)
                                   .Sum();
                var ratio = cloudMaxArea / squareArea;

                ratio.Should().BeLessThan(5);
            }