Example #1
0
        public void ShapeZ_rotate2_EnoughSpace()
        {
            IBoard board              = new Board();
            ShapeZ shapeTest          = new ShapeZ(board);
            ShapeZ shapeTest_expected = new ShapeZ(board);
            String expected           = "(5, 1)(4, 1)(5, 2)(6, 2)";

            /*      first row of the board
             *          Initial position
             *
             * [ ][ ][ ][ ][b][a][ ][ ][ ][ ]
             * [ ][ ][ ][ ][ ][c][d][ ][ ][ ]
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             */

            shapeTest.MoveDown();

            shapeTest.Rotate();
            shapeTest.Rotate();

            /*      Should look like this after rotating once
             *
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             * [ ][ ][ ][ ][b][a][ ][ ][ ][ ]
             * [ ][ ][ ][ ][ ][c][d][ ][ ][ ]
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             *
             */
            Assert.AreEqual(expected, shapeTest.getPositionOfBlocks());
        }
Example #2
0
        public void ShapeZ_Rotate_NoSpace()
        {
            IBoard board              = new Board();
            ShapeZ shapeTest          = new ShapeZ(board);
            ShapeZ shapeTest_expected = new ShapeZ(board);
            String expected           = "(5, 0)(4, 0)(5, 1)(6, 1)";


            /*      first row of the board
             *          Initial position
             *
             * [ ][ ][ ][ ][b][a][ ][ ][ ][ ]
             * [ ][ ][ ][ ][ ][c][d][ ][ ][ ]
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             */

            //Act
            shapeTest.Rotate();

            /*      Should look like this after attempting to rotate
             *
             * [ ][ ][ ][ ][b][a][ ][ ][ ][ ]
             * [ ][ ][ ][ ][ ][c][d][ ][ ][ ]
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             */

            Assert.AreEqual(expected, shapeTest.getPositionOfBlocks());
        }
Example #3
0
        public void Rotate_ShapeZ()
        {
            //arange
            IBoard board = new TestBoard(createEmptyBoard(10, 10));
            IShape shape = new ShapeZ(board);

            //act
            shape.MoveDown();
            shape.Rotate();
            int x1 = shape[0].Position.X;
            int y1 = shape[0].Position.Y;

            shape.Rotate();
            int x2 = shape[0].Position.X;
            int y2 = shape[0].Position.Y;

            //assert
            Assert.AreEqual(6, x1);             //expected, actual
            Assert.AreEqual(2, y1);
            Assert.AreEqual(5, x2);             //expected, actual
            Assert.AreEqual(1, y2);
        }
Example #4
0
        public void ShapeZ_Reset()
        {
            IBoard board              = new Board();
            ShapeZ shapeTest          = new ShapeZ(board);
            ShapeZ shapeTest_expected = new ShapeZ(board);
            String expected           = "(5, 0)(4, 0)(5, 1)(6, 1)";

            /*      first row of the board
             *          Initial position
             *
             * [ ][ ][ ][ ][b][a][ ][ ][ ][ ]
             * [ ][ ][ ][ ][ ][c][d][ ][ ][ ]
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             */

            //Act

            shapeTest.MoveDown();
            shapeTest.MoveDown();
            shapeTest.MoveLeft();
            shapeTest.MoveLeft();
            shapeTest.MoveLeft();
            shapeTest.Rotate();

            /*     Should look like this after reset.
             * [ ][ ][ ][ ][b][a][ ][ ][ ][ ]
             * [ ][ ][ ][ ][ ][c][d][ ][ ][ ]
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             */

            shapeTest.Reset();
            //Assert
            Assert.AreEqual(expected, shapeTest.getPositionOfBlocks());
        }