public void TestTryMovePawn_CommandPawnDownRight2()
        {
            ChessboardManager chessboardManager = new ChessboardManager();

            ChessPiece chessPieceBefore = chessboardManager.GetChessPiece('A');

            bool success = chessboardManager.TryMovePawn("ADR");

            Assert.IsTrue(success);

            ChessPiece chessPieceAfter = chessboardManager.GetChessPiece('A');

            Assert.AreEqual(chessPieceBefore.Row + 1, chessPieceAfter.Row, "Pawn position is incorrect.");
            Assert.AreEqual(chessPieceBefore.Col + 1, chessPieceAfter.Col, "Pawn position is incorrect.");
        }
        public void TestKingWins_Case1()
        {
            ChessboardManager chessboardManager = new ChessboardManager();

            chessboardManager.TryMoveKing("KUL");
            chessboardManager.TryMoveKing("KUL");
            chessboardManager.TryMoveKing("KUL");
            chessboardManager.TryMoveKing("KUR");
            chessboardManager.TryMoveKing("KUR");
            chessboardManager.TryMoveKing("KUR");

            chessboardManager.TryMovePawn("CDR");

            chessboardManager.TryMoveKing("KUR");

            Assert.IsTrue(
                chessboardManager.KingWins(),
                "The check whether the king wins doesn't work correctly.");
        }
        public void TestKingMovesCount()
        {
            ChessboardManager chessboardManager = new ChessboardManager();

            chessboardManager.TryMoveKing("KUL");
            chessboardManager.TryMoveKing("KUL");
            chessboardManager.TryMoveKing("KUL");
            chessboardManager.TryMoveKing("KUR");
            chessboardManager.TryMoveKing("KUR");
            chessboardManager.TryMoveKing("KUR");

            chessboardManager.TryMovePawn("CDR");

            chessboardManager.TryMoveKing("KUR");

            Assert.AreEqual(
                7,
                chessboardManager.KingMovesCount,
                "The moves made by the king are not counted correctly.");
        }
        public void TestKingWins_Case3()
        {
            ChessboardManager chessboardManager = new ChessboardManager();

            chessboardManager.TryMoveKing("KUL");
            chessboardManager.TryMovePawn("ADR");
            chessboardManager.TryMoveKing("KDL");
            chessboardManager.TryMoveKing("KUR");
            chessboardManager.TryMoveKing("KUL");
            chessboardManager.TryMovePawn("ADR");
            chessboardManager.TryMoveKing("KDR");

            // the king: (5, 1)
            chessboardManager.TryMoveKing("KUL");
            chessboardManager.TryMoveKing("KUR");
            chessboardManager.TryMovePawn("DDR");
            chessboardManager.TryMoveKing("KUL");

            // pawn C: (1, 5)
            chessboardManager.TryMovePawn("CDR");

            // pawn B: (1, 3)
            chessboardManager.TryMovePawn("BDR");

            // the king: (2, 0)
            chessboardManager.TryMoveKing("KUL");
            chessboardManager.TryMovePawn("DDL");

            // the king: (1, 1)
            chessboardManager.TryMoveKing("KUR");
            chessboardManager.TryMoveKing("KUR");

            Assert.IsTrue(
                chessboardManager.KingWins(),
                "The check whether the king wins doesn't work correctly.");
        }
        public void TestKingWins_Case2()
        {
            ChessboardManager chessboardManager = new ChessboardManager();

            chessboardManager.TryMoveKing("KUR");
            chessboardManager.TryMovePawn("BDL");
            chessboardManager.TryMoveKing("KUL");
            chessboardManager.TryMovePawn("CDL");
            chessboardManager.TryMoveKing("KUR");
            chessboardManager.TryMovePawn("DDL");
            chessboardManager.TryMoveKing("KUR");
            chessboardManager.TryMovePawn("DDL");
            chessboardManager.TryMoveKing("KUR");
            chessboardManager.TryMovePawn("CDL");
            chessboardManager.TryMoveKing("KUL");
            chessboardManager.TryMovePawn("BDL");
            chessboardManager.TryMoveKing("KUL");

            Assert.AreEqual(7, chessboardManager.KingMovesCount, "King moves are not counted correctly.");

            Assert.IsTrue(
                chessboardManager.KingWins(),
                "The check whether the king wins doesn't work correctly.");
        }
        public void TestKingWins_PawnsCanMoveAndKingNotAtRow0()
        {
            ChessboardManager chessboardManager = new ChessboardManager();

            chessboardManager.TryMovePawn("ADR");
            chessboardManager.TryMovePawn("ADR");
            chessboardManager.TryMovePawn("ADR");
            chessboardManager.TryMovePawn("ADR");
            chessboardManager.TryMovePawn("ADR");

            chessboardManager.TryMovePawn("BDR");
            chessboardManager.TryMovePawn("BDR");
            chessboardManager.TryMovePawn("BDR");
            chessboardManager.TryMovePawn("BDR");
            chessboardManager.TryMovePawn("BDR");
            chessboardManager.TryMovePawn("BDL");

            chessboardManager.TryMovePawn("CDL");
            chessboardManager.TryMovePawn("CDL");
            chessboardManager.TryMovePawn("CDL");
            chessboardManager.TryMovePawn("CDL");
            chessboardManager.TryMovePawn("CDR");
            chessboardManager.TryMovePawn("CDR");

            chessboardManager.TryMovePawn("DDL");
            chessboardManager.TryMovePawn("DDL");
            chessboardManager.TryMovePawn("DDL");
            chessboardManager.TryMovePawn("DDL");
            chessboardManager.TryMovePawn("DDL");

            // the king does not reach row 0
            chessboardManager.TryMoveKing("KUR");
            chessboardManager.TryMoveKing("KUL");
            chessboardManager.TryMoveKing("KUL");
            chessboardManager.TryMoveKing("KUR");
            chessboardManager.TryMoveKing("KUL");
            chessboardManager.TryMoveKing("KUL");

            Assert.IsFalse(
                chessboardManager.KingWins(),
                "The check whether the king wins doesn't work correctly.");
        }
        public void TestKingWins_PawnsCannotMoveAnyFurther()
        {
            ChessboardManager chessboardManager = new ChessboardManager();

            // A reaches line 7
            chessboardManager.TryMovePawn("ADR");
            chessboardManager.TryMovePawn("ADR");
            chessboardManager.TryMovePawn("ADR");
            chessboardManager.TryMovePawn("ADR");
            chessboardManager.TryMovePawn("ADR");
            chessboardManager.TryMovePawn("ADR");
            chessboardManager.TryMovePawn("ADR");

            // B reaches line 7
            chessboardManager.TryMovePawn("BDR");
            chessboardManager.TryMovePawn("BDR");
            chessboardManager.TryMovePawn("BDR");
            chessboardManager.TryMovePawn("BDR");
            chessboardManager.TryMovePawn("BDR");
            chessboardManager.TryMovePawn("BDL");
            chessboardManager.TryMovePawn("BDL");

            // C reaches line 7
            chessboardManager.TryMovePawn("CDL");
            chessboardManager.TryMovePawn("CDL");
            chessboardManager.TryMovePawn("CDL");
            chessboardManager.TryMovePawn("CDL");
            chessboardManager.TryMovePawn("CDR");
            chessboardManager.TryMovePawn("CDR");
            chessboardManager.TryMovePawn("CDL");

            // D gets blocked at (6, 0) by C which is at (7, 1)
            chessboardManager.TryMovePawn("DDL");
            chessboardManager.TryMovePawn("DDL");
            chessboardManager.TryMovePawn("DDL");
            chessboardManager.TryMovePawn("DDL");
            chessboardManager.TryMovePawn("DDL");
            chessboardManager.TryMovePawn("DDL");

            // The king does not need to reach row 0 to win.
            Assert.IsTrue(
                chessboardManager.KingWins(),
                "The check whether the king wins doesn't work correctly.");
        }