コード例 #1
0
        public void TestLineMoveRightSuccess()
        {
            for (int row = 0; row < 4; ++row)
            {
                var chessBoard = new ChessBoard();
                var levels     = ChessBoardHandler.GetRandomDistinctLevels(2);
                var cols       = RandomGenerator.GetDistinctInts(2, 0, 3);

                chessBoard.AddNew(new Position(row, cols[0]), levels[0]);
                chessBoard.AddNew(new Position(row, cols[1]), levels[1]);

                Assert.AreEqual(chessBoard.Move(Direction.Right), true);
                Assert.AreEqual(chessBoard.EmptyCount, 14);
            }
        }
コード例 #2
0
        public void TestMoveRightOneDistinctLineFail()
        {
            for (int row = 0; row < 4; ++row)
            {
                var chessBoard = new ChessBoard();
                var levels     = ChessBoardHandler.GetRandomDistinctLevels(4);

                chessBoard.AddNew(new Position(row, 0), levels[0]);
                chessBoard.AddNew(new Position(row, 1), levels[1]);
                chessBoard.AddNew(new Position(row, 2), levels[2]);
                chessBoard.AddNew(new Position(row, 3), levels[3]);

                Assert.AreEqual(chessBoard.Move(Direction.Right), false);
            }
        }
コード例 #3
0
        public void TestLineMoveDownSuccess()
        {
            for (int col = 0; col < 4; ++col)
            {
                var chessBoard = new ChessBoard();
                var levels     = ChessBoardHandler.GetRandomDistinctLevels(2);
                var rows       = RandomGenerator.GetDistinctInts(2, 0, 3);

                chessBoard.AddNew(new Position(rows[0], col), levels[0]);
                chessBoard.AddNew(new Position(rows[1], col), levels[1]);

                Assert.AreEqual(chessBoard.Move(Direction.Down), true);
                Assert.AreEqual(chessBoard.EmptyCount, 14);
            }
        }
コード例 #4
0
        public void TestDistinctLineMoveDownFail()
        {
            for (int col = 0; col < 4; ++col)
            {
                var chessBoard = new ChessBoard();
                var levels     = ChessBoardHandler.GetRandomDistinctLevels(4);

                chessBoard.AddNew(new Position(0, col), levels[0]);
                chessBoard.AddNew(new Position(1, col), levels[1]);
                chessBoard.AddNew(new Position(2, col), levels[2]);
                chessBoard.AddNew(new Position(3, col), levels[3]);

                Assert.AreEqual(chessBoard.Move(Direction.Down), false);
            }
        }
コード例 #5
0
        public void TestLineMoveUpMergeTwice()
        {
            for (int col = 0; col < 4; ++col)
            {
                var chessBoard = new ChessBoard();
                var levels     = ChessBoardHandler.GetRandomDistinctLevels(2);

                chessBoard.AddNew(new Position(0, col), levels[0]);
                chessBoard.AddNew(new Position(1, col), levels[0]);
                chessBoard.AddNew(new Position(2, col), levels[1]);
                chessBoard.AddNew(new Position(3, col), levels[1]);

                Assert.AreEqual(chessBoard.Move(Direction.Up), true);
                Assert.AreEqual(chessBoard.EmptyCount, 14);
            }
        }
コード例 #6
0
        public void TestLineMoveRightMergeTwice()
        {
            for (int row = 0; row < 4; ++row)
            {
                var chessBoard = new ChessBoard();
                var levels     = ChessBoardHandler.GetRandomDistinctLevels(2);

                chessBoard.AddNew(new Position(row, 0), levels[0]);
                chessBoard.AddNew(new Position(row, 1), levels[0]);
                chessBoard.AddNew(new Position(row, 2), levels[1]);
                chessBoard.AddNew(new Position(row, 3), levels[1]);

                Assert.AreEqual(chessBoard.Move(Direction.Right), true);
                Assert.AreEqual(chessBoard.EmptyCount, 14);
            }
        }
コード例 #7
0
        public void TestLineMoveLeftMergeTwice()
        {
            for (int i = 0; i < 4; ++i)
            {
                var chessBoard = new ChessBoard();
                var levels     = ChessBoardHandler.GetRandomDistinctLevels(2);

                chessBoard.AddNew(new Position(i, 0), levels[0]);
                chessBoard.AddNew(new Position(i, 1), levels[0]);
                chessBoard.AddNew(new Position(i, 2), levels[1]);
                chessBoard.AddNew(new Position(i, 3), levels[1]);

                Assert.AreEqual(chessBoard.Move(Direction.Left), true);
                Assert.AreEqual(chessBoard.EmptyCount, 14);
            }
        }