Exemple #1
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);
        }
Exemple #2
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);
        }
Exemple #3
0
        public void ShapeI_Rotate_NoSpace()
        {
            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.Rotate();

            /*     Should keep original position if unable to rotate
             *
             * [ ][ ][ ][d][c][a][b][ ][ ][ ]
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             */


            //Assert
            Assert.AreEqual(expected, shapeTest.getPositionOfBlocks());
        }
Exemple #4
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());
        }
Exemple #5
0
        public void ShapeRotationShouldBeNinety()
        {
            // Arrange
            var shapeI = new ShapeI(0, 0, ShapeRotation.Zero);

            // Act
            shapeI.Rotate();

            // Assert
            shapeI.Rotation.Should().Be(ShapeRotation.Ninety);
        }
Exemple #6
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());
        }
Exemple #7
0
        public void Rotate_ShapeI_NoSpace()
        {
            //arange
            IBoard board = new TestBoard(createEmptyBoard(10, 10));
            IShape shape = new ShapeI(board);

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

            //assert
            Assert.AreEqual(7, x);             //expected, actual
            Assert.AreEqual(0, y);
        }
Exemple #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());
        }