Beispiel #1
0
        /// <summary>
        /// Configured desired shapes in the cartesian plane
        /// </summary>
        /// <returns></returns>
        private CartesianPlane CreateNewCartesianPlaneOn60X60GridWithIsoscelesRightTriangles()
        {
            int maxX = 60;
            int maxY = 60;
            int nonHypotenuseSideLengthInPixels = 10;

            var strategyProperties = new IsoscelesTriangleCreatorStrategyProperties();

            strategyProperties.NonHypotenuseSideLengthInPixels = nonHypotenuseSideLengthInPixels;
            strategyProperties.GridMaxXCoordinateInPixels      = maxX;
            strategyProperties.GridMaxYCoordinateInPixels      = maxY;
            strategyProperties.IncreaseCountOn = IsoscelesTriangleCreatorStrategyProperties.IncreaseCountOns
                                                 .IncreaseCountOnRightTriangle;
            strategyProperties.TriangleHypotenusePosition = IsoscelesTriangleCreatorStrategyProperties
                                                            .TriangleHypotenusePositions.BackslashHypotenuse;
            strategyProperties.StartRowOption =
                IsoscelesTriangleCreatorStrategyProperties.StartRowOptions.StartRowAtMaxY;

            var strategy = new IsoscelesTriangleCreatorStrategy(strategyProperties);

            var plane = new CartesianPlane(maxX, maxY);

            plane.AddShapes(strategy.GenerateShapes());
            return(plane);
        }
Beispiel #2
0
        public void AddShapes_ExecutesSuccessfully(int shapesCount)
        {
            var plane  = new CartesianPlane(10, 10);
            var shapes = new List <Shape>();

            for (int i = 0; i < shapesCount; i++)
            {
                shapes.Add(new Shape(new List <Coordinate> {
                    new Coordinate(i, i)
                }, $"A{i}"));
            }
            plane.AddShapes(shapes);
            plane.ShapesCount.Should().Be(shapesCount);
        }