示例#1
0
        public void ShapeI_MoveLeft_NoSpace()
        {
            Board  board              = new Board();
            ShapeI shapeTest          = new ShapeI(board);
            ShapeI shapeTest_expected = new ShapeI(board);
            String expected           = "(2, 0)(3, 0)(1, 0)(0, 0)";


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


            //Act
            shapeTest.MoveLeft();
            shapeTest.MoveLeft();
            shapeTest.MoveLeft();

            /*
             *  Move the piece three times to the left to put it near the left border
             *  [d][c][a][b][ ][ ][ ][ ][ ][ ]
             *
             */

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


            //Assert
            Assert.AreEqual(expected, shapeTest.getPositionOfBlocks());
        }
示例#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());
        }
示例#3
0
        public void MoveLeft_NoSpace_EmptyBoard()
        {
            //arange
            IBoard board = new TestBoard(createEmptyBoard(10, 1));
            IShape shape = new ShapeI(board);

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

            //assert
            Assert.AreEqual(0, x);             //expected, actual
            Assert.AreEqual(0, y);
        }
        public void TestMoveLeft()
        {
            var shape = new ShapeI(new Point(2, 3));
            shape.MoveLeft();

            Assert.AreEqual(1, shape.Tiles[0].Position.X);
            Assert.AreEqual(2, shape.Tiles[1].Position.X);
            Assert.AreEqual(3, shape.Tiles[2].Position.X);
            Assert.AreEqual(4, shape.Tiles[3].Position.X);
        }
示例#5
0
        public void MoveLeft_NoSpace_BoardWithLine()
        {
            //arange
            IBoard board = new TestBoard
                               (createBoardWithLineVert(3, 1, (i => i < 10)));
            IShape shape = new ShapeI(board);

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

            //assert
            Assert.AreEqual(4, x);             //expected, actual
            Assert.AreEqual(0, y);
        }
示例#6
0
        public void ShapeI_MoveLeft_EnoughSpace()
        {
            Board  board              = new Board();
            ShapeI shapeTest          = new ShapeI(board);
            ShapeI shapeTest_expected = new ShapeI(board);
            String expected           = "(4, 0)(5, 0)(3, 0)(2, 0)";

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

            //Act
            shapeTest.MoveLeft();

            /*      AFter moving one to the left
             * [ ][ ][d][c][a][b][ ][ ][ ][ ]
             *
             */
            //Assert
            Assert.AreEqual(expected, shapeTest.getPositionOfBlocks());
        }