Exemplo n.º 1
0
 public void BoardDetectsBottomLinesEvenIfNoCurrentPieceLeans()
 {
     var board = new Board(2, 3);
     board.AddNewPiece();
     board.AddNewBlock(1, 2);
     board.AddNewBlock(0, 2);
     //BB
     //BB
     Assert.AreEqual(2, board.GetBlocks().Count());
     board.Advance();
     Assert.AreEqual(0, board.GetBlocks().Count());
 }
Exemplo n.º 2
0
 public void WhenPuttingAPieceItTheCurrentPiecePlacesAtZeroHeight()
 {
     var board = new Board();
     board.AddNewPiece();
     Assert.AreEqual(0, board.CurrentPiece.Y);
 }
Exemplo n.º 3
0
        public void WhenCurrentPieceReachesBottomVerifyesIfThereIsLineEvenForComplexPieces()
        {
            var board = new Board(3, 5);
            var block1 = new Block(0, 0);
            var block2 = new Block(2, 0);
            board.AddNewPiece(new[] { block1, block2 });
            board.AddNewBlock(1, 4);
            // P P
            //
            //
            //
            //  X
            Assert.AreEqual(1, board.GetBlocks().Count());
            board.Advance(); //1
            board.Advance();
            board.Advance();
            board.Advance(); //4
            board.Advance();

            Assert.IsNull(board.CurrentPiece);
            Assert.AreEqual(0, board.GetBlocks().Count());
        }
Exemplo n.º 4
0
        public void WhenPieceReachesBottomItsBlocksBecamePartOfTheBoard()
        {
            var board = new Board(2, 3);
            board.AddNewPiece();
            var block = board.CurrentPiece.GetBlocks().First();

            board.Advance();
            board.Advance();
            board.Advance();//no deberia hacer linea

            Assert.IsTrue(board.Contains(block));
        }
Exemplo n.º 5
0
 public void WhenCurrentPieceColidesWithIsolatedBlocksEvenForComplexPieces()
 {
     var board = new Board(3, 3);
     var block1 = new Block(0, 0);
     var block2 = new Block(2, 0);
     board.AddNewPiece(new[] { block1, block2 });
     board.AddNewBlock(2, 2);
     board.AddNewBlock(1, 0);
     // PXP
     //
     //   X
     Assert.AreEqual(2, board.GetBlocks().Count());
     board.Advance(); //1
     Assert.AreEqual(2, board.GetBlocks().Count());
     Assert.IsNotNull(board.CurrentPiece);
     board.Advance(); //2
     Assert.IsNull(board.CurrentPiece);
     Assert.AreEqual(4, board.GetBlocks().Count());
 }
Exemplo n.º 6
0
 public void WhenCurrentPieceReachesBottomVerifyesIfThereIsLine()
 {
     var board = new Board(2, 3);
     board.AddNewBlock(1, 2);
     board.AddNewPiece(); //0
     board.Advance(); //1
     board.Advance(); //2
     board.Advance(); //La pieza se apoyó.
     Assert.AreEqual(0, board.GetBlocks().Count());
 }
Exemplo n.º 7
0
 public void WhenBoardAdvancesCurrentPieceGoesDown()
 {
     var board = new Board(30);
     board.AddNewPiece();
     for (int i = 0; i <= 20; i++)
     {
         Assert.AreEqual(i, board.CurrentPiece.Y);
         board.Advance();
     }
     Assert.AreEqual(21, board.CurrentPiece.Y);
 }
Exemplo n.º 8
0
 public void WhenBoardFirstAdvancesCurrentPieceGoesDown()
 {
     var board = new Board();
     board.AddNewPiece();
     board.Advance();
     Assert.AreEqual(1, board.CurrentPiece.Y);
 }
Exemplo n.º 9
0
 public void WhenAdvancesPieceBlocksAlsoAdvanceEvenForComplexPieces()
 {
     var board = new Board(4, 5);
     var block1 = new Block(2, 0);
     var block2 = new Block(3, 1);
     board.AddNewPiece(new[] { block1, block2 });
     board.Advance();
     Assert.AreEqual(2, block1.X);
     Assert.AreEqual(1, block1.Y);
     Assert.AreEqual(3, block2.X);
     Assert.AreEqual(2, block2.Y);
 }
Exemplo n.º 10
0
 public void WhenAdvancesPieceBlocksAlsoAdvance()
 {
     var board = new Board();
     board.AddNewPiece();
     Assert.AreEqual(0, board.CurrentPiece.GetBlocks().First().Y);
     board.Advance();
     Assert.AreEqual(1, board.CurrentPiece.GetBlocks().First().Y);
 }
Exemplo n.º 11
0
 public void WhenAddingPieceCurrentPieceExists()
 {
     var board = new Board();
     board.AddNewPiece();
     Assert.IsNotNull(board.CurrentPiece);
 }
Exemplo n.º 12
0
        public void PiecesAreLeanedAlsoOnIsolatedBlocks()
        {
            var board = new Board(2, 4);
            //
            //
            //B
            //
            var isolated = board.AddNewBlock(0, 2);
            board.AddNewPiece();
            var pieceBlock = board.CurrentPiece.GetBlocks().Single();
            board.Advance();
            board.Advance();
            Assert.AreEqual(2, board.GetBlocks().Count());
            Assert.IsTrue(board.GetBlocks().Contains(isolated));
            Assert.IsTrue(board.GetBlocks().Contains(pieceBlock));

            Assert.AreEqual(2, isolated.Y);
            Assert.AreEqual(0, isolated.X);

            Assert.AreEqual(1, pieceBlock.Y);
            Assert.AreEqual(0, pieceBlock.X);
        }
Exemplo n.º 13
0
 public void CurrentPieceAdvancesUntilBottom()
 {
     var board = new Board(3);
     board.AddNewPiece(); //0
     board.Advance(); //1
     board.Advance(); //2
     Assert.AreEqual(2, board.CurrentPiece.Y);
     board.Advance();
     Assert.IsNull(board.CurrentPiece);
 }