public new void SetUp() { foreach (var testSize in RandomTestSizes) { CloudLayoutCreator.PutNextRectangle(testSize); } }
public void Should_EquallyStretchFigure_InBothAxis() { var stretchCoefficient = (double)CloudLayoutCreator.GetInscribedSquare().Width / CloudLayoutCreator.GetCircumscribedSquare().Width; stretchCoefficient .Should() .BeGreaterOrEqualTo(0.8, "Figure stretched a lot in one axis"); }
public void Should_DenselyPlaceRectangles_InShapeLikeSquare() { var rectangles = CloudLayoutCreator.GetAllRectangles().ToList(); var inscribedSquare = CloudLayoutCreator.GetInscribedSquare(); // check if we don't have outliers rectangles .All(rect => inscribedSquare.IntersectsWith(rect)) .Should() .BeTrue("Inner square should intersect with every rectangle"); }
public void Should_DenselyLocateRectangles_InCircumscribedSquare() { var circumscribedSquare = CloudLayoutCreator.GetCircumscribedSquare(); var actualRectanglesAres = CloudLayoutCreator.GetAllRectangles().Sum(rect => rect.Width * rect.Height); var denseCoefficient = (double)actualRectanglesAres / (circumscribedSquare.Width * circumscribedSquare.Width); denseCoefficient .Should() .BeGreaterThan(0.5); }
public void Should_DenselyPlaceRectangles_SymmetricByCoordinates() { // This test also checks that figure inscribes in square var rectangles = CloudLayoutCreator.GetAllRectangles().ToList(); IsSymmetricOverAxis(rectangles, rect => rect.X, rect => rect.Width) .Should() .BeTrue("Figure don't symmetric over x axis"); IsSymmetricOverAxis(rectangles, rect => rect.Y, rect => rect.Height) .Should() .BeTrue("Figure don't symmetric over y axis"); }
public void Should_ThrowException_WhenNextRectangleIsDegenerate(int width, int height) { Action a = () => CloudLayoutCreator.PutNextRectangle(new Size(width, height)); a.Should().Throw <ArgumentException>(); }