public void TestKingLoses_ReturnsFalse() { ChessboardManager chessboardManager = new ChessboardManager(); // move the king to (2, 2) chessboardManager.TryMoveKing("KUL"); chessboardManager.TryMoveKing("KUL"); chessboardManager.TryMoveKing("KUL"); chessboardManager.TryMoveKing("KUR"); chessboardManager.TryMoveKing("KUR"); // move pawn A to (1, 1) chessboardManager.TryMovePawn("ADR"); // move pawn B to (1, 3) chessboardManager.TryMovePawn("BDR"); // move pawn C to (1, 5) chessboardManager.TryMovePawn("CDR"); // move pawn D to (1, 7) chessboardManager.TryMovePawn("DDR"); Assert.IsFalse( chessboardManager.KingLoses(), "The check whether the king loses doesn't work correctly."); }
public void TestTryMoveKing_CommandKingUpLeft1() { ChessboardManager chessboardManager = new ChessboardManager(); bool success = chessboardManager.TryMoveKing("KUL"); Assert.IsTrue(success, "Command execution fails for the valid command \"KUL\"."); }
public void TestTryMoveKing_InvalidCommand1() { ChessboardManager chessboardManager = new ChessboardManager(); bool success = chessboardManager.TryMoveKing("qwerty"); Assert.IsFalse(success, "Move king command returns success for invalid commands."); }
public void TestTryMoveKing_InvalidCommand2() { ChessboardManager chessboardManager = new ChessboardManager(); bool success = chessboardManager.TryMoveKing("KDR"); Assert.IsFalse(success, "Move king to an invalid position returns success."); }
public void TestTryMoveKing_CommandKingUpLeft2() { ChessboardManager chessboardManager = new ChessboardManager(); ChessPiece chessPieceBefore = chessboardManager.GetChessPiece('K'); bool success = chessboardManager.TryMoveKing("KUL"); Assert.IsTrue(success); ChessPiece chessPieceAfter = chessboardManager.GetChessPiece('K'); Assert.AreEqual(chessPieceBefore.Row - 1, chessPieceAfter.Row, "King position is incorrect."); Assert.AreEqual(chessPieceBefore.Col - 1, chessPieceAfter.Col, "King 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_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_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_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."); }