public void white_left_castle_correct() { var game = new ClassicGame(); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(1, 0), new Position(0, 2))); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(2, 6), new Position(2, 4))); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(2, 1), new Position(2, 3))); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(3, 6), new Position(3, 4))); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(3, 1), new Position(3, 3))); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(1, 6), new Position(1, 4))); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(2, 0), new Position(3, 1))); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(0, 6), new Position(0, 4))); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(3, 0), new Position(2, 1))); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(4, 6), new Position(4, 4))); /*-----------------------------------------------------------------------------------*/ var castleMove = new BoardMove(new Position(4, 0), new Position(2, 0)); var leftRook = game.Board.GetPiece(new Position(0, 0)); ChessAssert.IsMoveCorrect(game, castleMove); Assert.IsNull(game.Board.GetPiece(new Position(0, 0))); Assert.AreSame(leftRook, game.Board.GetPiece(new Position(3, 0))); Assert.AreEqual(leftRook.Position, new Position(3, 0)); }
public void checkmate_white_win_game() { var game = new ClassicGame(); Assert.AreEqual(game.GameState, GameState.NotStarted); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(4, 1), new Position(4, 3))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(5, 6), new Position(5, 4))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(5, 1), new Position(5, 3))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(6, 6), new Position(6, 4))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(3, 0), new Position(7, 4))); Assert.AreEqual(game.GameState, GameState.Ended); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.Checkmated); }
public void pawns_move_correct() { var game = new ClassicGame(); for (int x = 0; x < game.Board.Width; x++) { ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(x, 1), new Position(x, 2))); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(x, 6), new Position(x, 5))); } }
public void white_right_castle_correct() { var game = new ClassicGame(); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(6, 0), new Position(7, 2))); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(5, 6), new Position(5, 4))); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(6, 1), new Position(6, 2))); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(6, 6), new Position(6, 4))); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(5, 0), new Position(6, 1))); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(7, 6), new Position(7, 4))); /*-----------------------------------------------------------------------------------*/ var castleMove = new BoardMove(new Position(4, 0), new Position(6, 0)); var rightRook = game.Board.GetPiece(new Position(7, 0)); ChessAssert.IsMoveCorrect(game, castleMove); Assert.IsNull(game.Board.GetPiece(new Position(7, 0))); Assert.AreSame(rightRook, game.Board.GetPiece(new Position(5, 0))); Assert.AreEqual(rightRook.Position, new Position(5, 0)); }
public void black_right_castle_correct() { var game = new ClassicGame(); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(0, 1), new Position(0, 3))); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(6, 7), new Position(7, 5))); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(1, 1), new Position(1, 3))); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(6, 6), new Position(6, 5))); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(2, 1), new Position(2, 3))); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(5, 7), new Position(6, 6))); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(3, 1), new Position(3, 3))); /*-----------------------------------------------------------------------------------*/ var castleMove = new BoardMove(new Position(4, 7), new Position(6, 7)); var rightRook = game.Board.GetPiece(new Position(7, 7)); ChessAssert.IsMoveCorrect(game, castleMove); Assert.IsNull(game.Board.GetPiece(new Position(7, 7))); Assert.AreSame(rightRook, game.Board.GetPiece(new Position(5, 7))); Assert.AreEqual(rightRook.Position, new Position(5, 7)); }
public void black_stalemate_full_game() { var game = new ClassicGame(); Assert.AreEqual(game.GameState, GameState.NotStarted); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(4, 1), new Position(4, 2))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(0, 6), new Position(0, 4))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(3, 0), new Position(7, 4))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(0, 7), new Position(0, 5))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(7, 4), new Position(0, 4))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(7, 6), new Position(7, 4))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(7, 1), new Position(7, 3))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(0, 5), new Position(7, 5))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(0, 4), new Position(2, 6))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(5, 6), new Position(5, 5))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(2, 6), new Position(3, 6))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.Checked); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(4, 7), new Position(5, 6))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(3, 6), new Position(1, 6))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(3, 7), new Position(3, 2))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(1, 6), new Position(1, 7))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(3, 2), new Position(7, 6))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(1, 7), new Position(2, 7))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(5, 6), new Position(6, 5))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); /*-----------------------------------------------------------------------------------*/ ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(2, 7), new Position(4, 5))); Assert.AreEqual(game.GameState, GameState.Ended); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.Stalemated); }
public void white_stalemate_all_pieces_on_board_full_game() { var game = new ClassicGame(); Assert.AreEqual(game.GameState, GameState.NotStarted); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(3, 1), new Position(3, 3))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(3, 6), new Position(3, 5))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(3, 0), new Position(3, 1))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(4, 6), new Position(4, 4))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(0, 1), new Position(0, 3))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(4, 4), new Position(4, 3))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(3, 1), new Position(5, 3))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(5, 6), new Position(5, 4))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(7, 1), new Position(7, 2))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(5, 7), new Position(4, 6))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(5, 3), new Position(7, 1))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(2, 7), new Position(4, 5))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(0, 0), new Position(0, 2))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(2, 6), new Position(2, 4))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(0, 2), new Position(6, 2))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(3, 7), new Position(0, 4))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.Checked); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(1, 0), new Position(3, 1))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(4, 6), new Position(7, 3))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(5, 1), new Position(5, 2))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(4, 5), new Position(1, 2))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(3, 3), new Position(3, 4))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(4, 3), new Position(4, 2))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(2, 1), new Position(2, 3))); Assert.AreEqual(game.GameState, GameState.InProgress); Assert.AreEqual(game.WhiteKing.KingState, KingState.None); Assert.AreEqual(game.BlackKing.KingState, KingState.None); /*----------------------------------------------------------------------------------*/ ChessAssert.IsMoveCorrect(game, new BoardMove(new Position(5, 4), new Position(5, 3))); Assert.AreEqual(game.GameState, GameState.Ended); Assert.AreEqual(game.WhiteKing.KingState, KingState.Stalemated); Assert.AreEqual(game.BlackKing.KingState, KingState.None); }