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); }
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"); }
public void PlaceRectanglesFast() { var size = new Size(1, 1); for (int i = 0; i < 10000; ++i) { BaseLayouter.PutNextRectangle(size); } }
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(); }
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(); }
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); }