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


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

            //Act
            shapeTest.Rotate();

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

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


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

            //Act
            shapeTest.MoveDown();

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

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

            Assert.AreEqual(expected, shapeTest.getPositionOfBlocks());
        }
Пример #3
0
        public void TestMoveRight()
        {
            var shape = new ShapeS(new Point(2, 3));
            shape.MoveRight();

            Assert.AreEqual(3, shape.Tiles[0].Position.X);
            Assert.AreEqual(4, shape.Tiles[1].Position.X);
            Assert.AreEqual(4, shape.Tiles[2].Position.X);
            Assert.AreEqual(5, shape.Tiles[3].Position.X);
        }
Пример #4
0
        public void Rotate_ShapeS()
        {
            //arange
            IBoard board = new TestBoard(createEmptyBoard(10, 10));
            IShape shape = new ShapeS(board);

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

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

            //assert
            Assert.AreEqual(7, x1);             //expected, actual
            Assert.AreEqual(2, y1);
            Assert.AreEqual(5, x2);             //expected, actual
            Assert.AreEqual(2, y2);
        }
Пример #5
0
        public void ShapeS_Reset()
        {
            IBoard board              = new Board();
            ShapeS shapeTest          = new ShapeS(board);
            ShapeS shapeTest_expected = new ShapeS(board);
            String expected           = "(5, 0)(6, 0)(4, 1)(5, 1)";

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

            //Act

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

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

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