Пример #1
0
        public void ShapeO_MoveRight_EnoughSpace()
        {
            IBoard board              = new Board();
            ShapeO shapeTest          = new ShapeO(board);
            ShapeO shapeTest_expected = new ShapeO(board);
            String expected           = "(6, 0)(5, 0)(5, 1)(6, 1)";

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

            //Act
            shapeTest.MoveRight();

            /*      AFter moving one to the right
             * [ ][ ][ ][ ][ ][b][a][ ][ ][ ]
             * [ ][ ][ ][ ][ ][c][d][ ][ ][ ]
             *
             */
            //Assert
            Assert.AreEqual(expected, shapeTest.getPositionOfBlocks());
        }
Пример #2
0
        public void ShapeO_Rotate1_EnoughSpace()
        {
            IBoard board              = new Board();
            ShapeO shapeTest          = new ShapeO(board);
            ShapeO shapeTest_expected = new ShapeO(board);
            String expected           = "(5, 0)(4, 0)(4, 1)(5, 1)";

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

            shapeTest.Rotate();

            /*     O Shape stays the same
             * [ ][ ][ ][ ][b][a][ ][ ][ ][ ]
             * [ ][ ][ ][ ][c][d][ ][ ][ ][ ]
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             *
             */

            //Assert
            Assert.AreEqual(expected, shapeTest.getPositionOfBlocks());
        }
Пример #3
0
        public void ShapeO_MoveLeft_NoSpace()
        {
            IBoard board              = new Board();
            ShapeO shapeTest          = new ShapeO(board);
            ShapeO shapeTest_expected = new ShapeO(board);
            String expected           = "(1, 0)(0, 0)(0, 1)(1, 1)";

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

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

            /*     Moved to the border.
             * [b][a][ ][ ][ ][ ][ ][ ][ ][ ]
             * [c][d][ ][ ][ ][ ][ ][ ][ ][ ]
             *
             */

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

            //Assert
            Assert.AreEqual(expected, shapeTest.getPositionOfBlocks());
        }
Пример #4
0
        public void ShapeO_MoveDown_NoSpace()
        {
            IBoard board              = new Board();
            ShapeO shapeTest          = new ShapeO(board);
            ShapeO shapeTest_expected = new ShapeO(board);
            String expected           = "(5, 18)(4, 18)(4, 19)(5, 19)";

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

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

            /*     Moved to the border.
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             * [ ][ ][ ][ ][b][a][ ][ ][ ][ ]
             * [ ][ ][ ][ ][c][d][ ][ ][ ][ ]
             *
             */

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

            //Assert
            Assert.AreEqual(expected, shapeTest.getPositionOfBlocks());
        }
Пример #5
0
        public void AddToPile()
        {
            TestBoard board = new TestBoard();
            IShape    shape = new ShapeO(board);

            board.addToPile(shape);

            TestBoard board2 = new TestBoard();
            bool      same   = true;

            for (int i = 0; i < 2; i++)
            {
                board2[i, 5] = Color.Transparent;
                board2[i, 4] = Color.Transparent;
            }

            for (int i = 0; i < 2; i++)
            {
                if (board[i, 5] != board2[i, 5])
                {
                    same = false;
                }
                if (board[i, 4] != board2[i, 4])
                {
                    same = false;
                }
            }
            Assert.AreEqual(true, same);
        }
Пример #6
0
        public void TestMoveRight()
        {
            var shape = new ShapeO(new Point(2, 3));
            shape.MoveRight();

            Assert.AreEqual(3, shape.Tiles[0].Position.X);
            Assert.AreEqual(4, shape.Tiles[1].Position.X);
            Assert.AreEqual(3, shape.Tiles[2].Position.X);
            Assert.AreEqual(4, shape.Tiles[3].Position.X);
        }
Пример #7
0
        public void ShapeO_Reset()
        {
            IBoard board              = new Board();
            ShapeO shapeTest          = new ShapeO(board);
            ShapeO shapeTest_expected = new ShapeO(board);
            String expected           = "(5, 0)(4, 0)(4, 1)(5, 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();

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

            shapeTest.Reset();


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

            //Assert
            Assert.AreEqual(expected, shapeTest.getPositionOfBlocks());
        }
Пример #8
0
        public void Rotate_ShapeO()
        {
            //arange
            IBoard board = new TestBoard(createEmptyBoard(10, 10));
            IShape shape = new ShapeO(board);

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

            //assert
            Assert.AreEqual(5, x);             //expected, actual
            Assert.AreEqual(0, y);
        }
Пример #9
0
 public void visit(ShapeO sShape)
 {
     moveLeft(sShape);
 }
Пример #10
0
 public void visit(ShapeO sShape)
 {
     //not needed
 }
Пример #11
0
 public void visit(ShapeO sShape)
 {
     moveRight(sShape);
 }