Example #1
0
        public void ShapeI_MoveDown_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 one down
             * [ ][ ][ ][ ][ ][ ][ ][ ][ ][ ]
             * [ ][ ][ ][ ][d][c][a][b][ ][ ]
             *
             */
            //Assert
            Assert.AreEqual(expected, shapeTest.getPositionOfBlocks());
        }
Example #2
0
        public void ShapeI_MoveRight_NoSpace()
        {
            Board  board              = new Board();
            ShapeI shapeTest          = new ShapeI(board);
            ShapeI shapeTest_expected = new ShapeI(board);
            String expected           = "(8, 0)(9, 0)(7, 0)(6, 0)";


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


            //Act
            shapeTest.MoveRight();
            shapeTest.MoveRight();
            shapeTest.MoveRight();

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

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


            //Assert
            Assert.AreEqual(expected, shapeTest.getPositionOfBlocks());
        }
Example #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());
        }
Example #4
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);
        }
Example #5
0
        public void ShapeI_MoveDown_NoSpace()
        {
            Board  board              = new Board();
            ShapeI shapeTest          = new ShapeI(board);
            ShapeI shapeTest_expected = new ShapeI(board);
            String expected           = "(5, 19)(6, 19)(4, 19)(3, 19)";


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


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

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


            //Assert
            Assert.AreEqual(expected, shapeTest.getPositionOfBlocks());
        }
Example #6
0
        public void NextRotationYCorrectValueTest()
        {
            _shapeI = new ShapeI();
            int expected = _shapeI.Y + 1;
            int actual   = _shapeI.NextRotationY();

            Assert.AreEqual(expected, actual);
        }
Example #7
0
        public void NextRotationYIncorrectValueTest()
        {
            _shapeI          = new ShapeI();
            _shapeI.Rotation = 2;
            int expected = 1;
            int actual   = _shapeI.NextRotationY();

            Assert.AreNotEqual(expected, actual);
        }
Example #8
0
        public void WheelYChangeTest()
        {
            _shapeI = new ShapeI();
            int oldY = _shapeI.Y;

            _shapeI.Wheel();
            int newY = _shapeI.Y;

            Assert.IsTrue(oldY < newY);
        }
Example #9
0
        public void WheelXChangeTest()
        {
            _shapeI = new ShapeI();
            int oldX = _shapeI.X;

            _shapeI.Wheel();
            int newX = _shapeI.X;

            Assert.IsTrue(oldX > newX);
        }
Example #10
0
 public void NextRotationCorrectValueTest()
 {
     _shapeI         = new ShapeI();
     int[,] expected = new int[1, 4]
     {
         { 1, 1, 1, 1 }
     };
     int[,] actual = _shapeI.NextRotation(_shapeI.Rotation);
     Assert.AreEqual(expected.ToString(), actual.ToString());
 }
        public void TestMoveRight()
        {
            var shape = new ShapeI(new Point(2, 3));
            shape.MoveRight();

            Assert.AreEqual(3, shape.Tiles[0].Position.X);
            Assert.AreEqual(4, shape.Tiles[1].Position.X);
            Assert.AreEqual(5, shape.Tiles[2].Position.X);
            Assert.AreEqual(6, shape.Tiles[3].Position.X);
        }
Example #12
0
        public void ShapeRotationShouldBeNinety()
        {
            // Arrange
            var shapeI = new ShapeI(0, 0, ShapeRotation.Zero);

            // Act
            shapeI.Rotate();

            // Assert
            shapeI.Rotation.Should().Be(ShapeRotation.Ninety);
        }
Example #13
0
 public void visit(ShapeI iShape)
 {
     iShape.draw()[1].X++;
     iShape.draw()[1].Y--;
     iShape.draw()[2].X += 2;
     iShape.draw()[2].Y -= 2;
     iShape.draw()[3].X += 3;
     iShape.draw()[3].Y -= 3;
     iShape.setPos(12);
     iShape.findHighestCell();
     iShape.findLowestCell();
 }
Example #14
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);
        }
Example #15
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());
        }
Example #16
0
        public void MoveDown_EnoughSpace()
        {
            //arange
            IBoard board = new TestBoard(createEmptyBoard(10, 10));
            IShape shape = new ShapeI(board);

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

            //assert
            Assert.AreEqual(4, x);             //expected, actual
            Assert.AreEqual(1, y);
        }
Example #17
0
        public void Drop_NoSpace_EmptyBoard()
        {
            //arange
            IBoard board = new TestBoard(createEmptyBoard(10, 1));
            IShape shape = new ShapeI(board);

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

            //assert
            Assert.AreEqual(4, x);             //expected, actual
            Assert.AreEqual(0, y);
        }
Example #18
0
        public void Drop_EnoughSpace_BoardWithLine()
        {
            //arange
            IBoard board = new TestBoard(createBoardWithLineHor());
            IShape shape = new ShapeI(board);

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

            //assert
            Assert.AreEqual(4, x);             //expected, actual
            Assert.AreEqual(8, y);
        }
Example #19
0
        public void Move_OnJoinPile()
        {
            //arange
            IBoard board = new TestBoard(createEmptyBoard(10, 10));
            IShape shape = new ShapeI(board);

            bool eventJoin = false;

            shape.JoinPile += () => eventJoin = true;
            //act
            shape.Drop();

            //assert
            Assert.IsTrue(eventJoin);
        }
Example #20
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);
        }
Example #21
0
        public void BlockProperty_Return()
        {
            //arrange
            IBoard board = new TestBoard(createEmptyBoard(10, 10));
            IShape shape = new ShapeI(board);

            //act
            try
            {
                Block b = shape[-1];
                //arrange
                Assert.Fail();
            }
            catch (IndexOutOfRangeException e)
            { }
        }
Example #22
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);
        }
Example #23
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());
        }
Example #24
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());
        }
Example #25
0
        public void ShapeI_MoveRight_EnoughSpace()
        {
            Board  board              = new Board();
            ShapeI shapeTest          = new ShapeI(board);
            ShapeI shapeTest_expected = new ShapeI(board);
            String expected           = "(6, 0)(7, 0)(5, 0)(4, 0)";

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

            //Act
            shapeTest.MoveRight();

            /*      AFter moving one to the right
             * [ ][ ][ ][ ][d][c][a][b][ ][ ]
             *
             */
            //Assert
            Assert.AreEqual(expected, shapeTest.getPositionOfBlocks());
        }
Example #26
0
 public void YIncorrectValueTest()
 {
     _shapeI   = new ShapeI();
     _shapeI.Y = 17;
 }
Example #27
0
 public void XNegativeValueTest()
 {
     _shapeI   = new ShapeI();
     _shapeI.X = -2;
 }
Example #28
0
 public void XIncorrectValueTest()
 {
     _shapeI   = new ShapeI();
     _shapeI.X = 11;
 }
Example #29
0
 public void RotatioтNegativeValueTest()
 {
     _shapeI          = new ShapeI();
     _shapeI.Rotation = -1;
 }
Example #30
0
 public void visit(ShapeI iShape)
 {
     moveLeft(iShape);
 }
Example #31
0
 public void YNegativeValueTest()
 {
     _shapeI   = new ShapeI();
     _shapeI.Y = -1;
 }