Ejemplo n.º 1
0
        public void ShapeI_MoveDown_NoSpace()
        {
            Board  board              = new Board();
            ShapeI shapeTest          = new ShapeI(board);
            ShapeI shapeTest_expected = new ShapeI(board);
            String expected           = "(5, 19)(6, 19)(4, 19)(3, 19)";


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


            //Act - Move the piece to the bottom of board
            for (int i = 0; i < 20; i++)
            {
                shapeTest.MoveDown();
            }

            /*
             *  Now in the last row of the board
             *  [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             *  [ ][ ][ ][d][c][a][b][ ][ ][ ]
             *
             */

            //Now move once more to check if it goes outside the board
            shapeTest.MoveDown();


            //Assert
            Assert.AreEqual(expected, shapeTest.getPositionOfBlocks());
        }
Ejemplo n.º 2
0
        public void ShapeI_Reset()
        {
            Board  board              = new Board();
            ShapeI shapeTest          = new ShapeI(board);
            ShapeI shapeTest_expected = new ShapeI(board);
            String expected           = "(5, 0)(6, 0)(4, 0)(3, 0)";

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

            //Act

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

            /*     Position after moving
             *
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             * [ ][ ][b][ ][ ][ ][ ][ ][ ][ ]
             * [ ][ ][a][ ][ ][ ][ ][ ][ ][ ]
             * [ ][ ][c][ ][ ][ ][ ][ ][ ][ ]
             * [ ][ ][d][ ][ ][ ][ ][ ][ ][ ]
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             *
             */

            shapeTest.Reset();


            /*     Should be back to original position
             *
             * [ ][ ][ ][d][c][a][b][ ][ ][ ]
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             *
             */

            //Assert
            Assert.AreEqual(expected, shapeTest.getPositionOfBlocks());
        }
Ejemplo n.º 3
0
        public void Rotate_ShapeI_EnoughSpace()
        {
            //arange
            IBoard board = new TestBoard(createEmptyBoard(10, 10));
            IShape shape = new ShapeI(board);

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

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

            shape.Rotate();
            int x3 = shape[3].Position.X;
            int y3 = shape[3].Position.Y;

            //assert
            Assert.AreEqual(6, x1);             //expected, actual
            Assert.AreEqual(0, y1);
            Assert.AreEqual(7, x2);             //expected, actual
            Assert.AreEqual(1, y2);
            Assert.AreEqual(6, x1);             //expected, actual
            Assert.AreEqual(0, y1);
        }
Ejemplo n.º 4
0
        public void ShapeI_MoveDown_EnoughSpace()
        {
            Board  board              = new Board();
            ShapeI shapeTest          = new ShapeI(board);
            ShapeI shapeTest_expected = new ShapeI(board);
            String expected           = "(5, 1)(6, 1)(4, 1)(3, 1)";

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

            //Act
            shapeTest.MoveDown();

            /*      AFter moving one down
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             * [ ][ ][ ][ ][d][c][a][b][ ][ ]
             *
             */
            //Assert
            Assert.AreEqual(expected, shapeTest.getPositionOfBlocks());
        }
Ejemplo n.º 5
0
        public void ShapeI_Constructor()
        {
            //assign
            IBoard board = new TestBoard();
            Shape  i     = new ShapeI(board);

            //act
            i.MoveDown();
            i.Rotate();
            i.Rotate();
            //assert
            Assert.AreEqual(new Point(5, 1), i[1].Position);
        }
Ejemplo n.º 6
0
        public void MoveDown_EnoughSpace()
        {
            //arange
            IBoard board = new TestBoard(createEmptyBoard(10, 10));
            IShape shape = new ShapeI(board);

            //act
            shape.MoveDown();
            int x = shape[0].Position.X;
            int y = shape[0].Position.Y;

            //assert
            Assert.AreEqual(4, x);             //expected, actual
            Assert.AreEqual(1, y);
        }
Ejemplo n.º 7
0
        public void ShapeI_Rotate2_EnoughSpace()
        {
            Board  board              = new Board();
            ShapeI shapeTest          = new ShapeI(board);
            ShapeI shapeTest_expected = new ShapeI(board);
            String expected           = "(5, 1)(6, 1)(4, 1)(3, 1)";

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

            //Act
            shapeTest.MoveDown();


            /*      AFter moving down to allow space to rotate
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             * [ ][ ][ ][d][c][a][b][ ][ ][ ]
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             *
             */

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

            /*     Should keep original position after rotating twice.
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             * [ ][ ][ ][d][c][a][b][ ][ ][ ]
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             *
             */


            //Assert
            Assert.AreEqual(expected, shapeTest.getPositionOfBlocks());
        }
Ejemplo n.º 8
0
        public void ShapeI_Rotate1_EnoughSpace()
        {
            Board  board              = new Board();
            ShapeI shapeTest          = new ShapeI(board);
            ShapeI shapeTest_expected = new ShapeI(board);
            String expected           = "(5, 1)(5, 0)(5, 2)(5, 3)";

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

            //Act
            shapeTest.MoveDown();


            /*      AFter moving down to allow space to rotate
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             * [ ][ ][ ][d][c][a][b][ ][ ][ ]
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             *
             */

            shapeTest.Rotate();

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


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