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

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

            //Act

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

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

            shapeTest.Reset();
            //Assert
            Assert.AreEqual(expected, shapeTest.getPositionOfBlocks());
        }
Пример #2
0
        public void ShapeT_MoveRight_EnoughSpace()
        {
            IBoard board              = new Board();
            ShapeT shapeTest          = new ShapeT(board);
            ShapeT shapeTest_expected = new ShapeT(board);
            String expected           = "(6, 0)(7, 0)(5, 0)(6, 1)";

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

            shapeTest.MoveRight();


            /*
             * [ ][ ][ ][ ][ ][c][a][b][ ][ ]
             * [ ][ ][ ][ ][ ][ ][d][ ][ ][ ]
             *
             */

            Assert.AreEqual(expected, shapeTest.getPositionOfBlocks());
        }
Пример #3
0
        public void ShapeT_Rotate_NoSpace()
        {
            IBoard board              = new Board();
            ShapeT shapeTest          = new ShapeT(board);
            ShapeT shapeTest_expected = new ShapeT(board);
            String expected           = "(5, 0)(6, 0)(4, 0)(5, 1)";

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

            //act


            shapeTest.Rotate();


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


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

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

            shapeTest.MoveLeft();
            shapeTest.MoveLeft();
            shapeTest.MoveLeft();
            shapeTest.MoveLeft();

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

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

            Assert.AreEqual(expected, shapeTest.getPositionOfBlocks());
        }
Пример #5
0
 public void visit(ShapeT tShape)
 {
     tShape.draw()[0].Y -= 2;
     tShape.draw()[1].X++;
     tShape.draw()[1].Y--;
     tShape.draw()[3].X += 2;
     tShape.setPos(12);
     tShape.findLowestCell();
     tShape.findHighestCell();
 }
Пример #6
0
        public void TestMoveRight()
        {
            var shape = new ShapeT(new Point(2, 3));
            shape.MoveRight();

            Assert.AreEqual(4, shape.Tiles[0].Position.X);
            Assert.AreEqual(4, shape.Tiles[1].Position.X);
            Assert.AreEqual(4, shape.Tiles[2].Position.X);
            Assert.AreEqual(3, shape.Tiles[3].Position.X);
        }
Пример #7
0
 public void visit(ShapeT tShape)
 {
     tShape.draw()[0].X++;
     tShape.draw()[0].Y++;
     tShape.draw()[2].X++;
     tShape.draw()[2].Y--;
     tShape.draw()[3].X--;
     tShape.draw()[3].Y--;
     tShape.setPos(6);
     tShape.findLowestCell();
     tShape.findHighestCell();
 }
Пример #8
0
        public void ShapeT_Rotate4_EnoughSpace()
        {
            IBoard board              = new Board();
            ShapeT shapeTest          = new ShapeT(board);
            ShapeT shapeTest_expected = new ShapeT(board);
            String expected           = "(5, 1)(6, 1)(4, 1)(5, 2)";

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

            //Act
            shapeTest.MoveDown();


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

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

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


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

            //act
            Point[] arr = rotate(shape);

            //assert
            Assert.AreEqual(7, arr[0].X);             //expected, actual
            Assert.AreEqual(1, arr[0].Y);

            Assert.AreEqual(6, arr[1].X);
            Assert.AreEqual(0, arr[1].Y);

            Assert.AreEqual(5, arr[2].X);
            Assert.AreEqual(1, arr[2].Y);

            Assert.AreEqual(6, arr[3].X);
            Assert.AreEqual(2, arr[3].Y);
        }
Пример #10
0
        public void ShapeT_MoveDown_NoSpace()
        {
            IBoard board              = new Board();
            ShapeT shapeTest          = new ShapeT(board);
            ShapeT shapeTest_expected = new ShapeT(board);
            String expected           = "(5, 18)(6, 18)(4, 18)(5, 19)";

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


            //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
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             * [ ][ ][ ][ ][c][a][b][ ][ ][ ]
             * [ ][ ][ ][ ][ ][d][ ][ ][ ][ ]
             *
             */

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


            //Assert
            Assert.AreEqual(expected, shapeTest.getPositionOfBlocks());
        }
Пример #11
0
 public void visit(ShapeT tShape)
 {
     moveLeft(tShape);
 }
Пример #12
0
 public void visit(ShapeT tShape)
 {
     moveRight(tShape);
 }