public void IsMovePossible_PossibleMove_ReturnTrue(string pawnPositionsString, string moveString) { var pawn = (Pawn)_board[pawnPositionsString]; var move = MoveParser.ParseMove(moveString, _board); Assert.IsTrue(pawn.IsMovePossible(move)); }
public void IsMovePossible_PossibleMove_ReturnTrue(string bishopPositionString, string moveString) { var bishop = (Bishop)_board[bishopPositionString]; var move = MoveParser.ParseMove(moveString, _board); Assert.IsTrue(bishop.IsMovePossible(move)); }
public void IsMovePossible_PossibleMove_ReturnTrue(string knightPositionString, string moveString) { var knight = (Knight)_board[knightPositionString]; var move = MoveParser.ParseMove(moveString, _board); Assert.IsTrue(knight.IsMovePossible(move)); }
public void IsMovePossible_PossibleMove_ReturnTrue(string kingPositionString, string moveString) { var king = (King)_board[kingPositionString]; var move = MoveParser.ParseMove(moveString, _board); Assert.IsTrue(king.IsMovePossible(move)); }
public void IsMovePossible_PossibleMove_ReturnTrue(string rookPositionString, string moveString) { var rook = (Rook)_board[rookPositionString]; var move = MoveParser.ParseMove(moveString, _board); Assert.IsTrue(rook.IsMovePossible(move)); }
public static void ParseMove_CorrectNotation_ReturnExpectedEnPassant(string moveString, string expectedFromPositionString, string expectedToPositionString) { var expectedMove = new EnPassant((Pawn)_board[expectedFromPositionString], new Position(expectedToPositionString), _board); var move = MoveParser.ParseMove(moveString, _board); Assert.That(move.Equals(expectedMove)); }
private static IMove ReadMove(Board board) { var moveString = Console.ReadLine(); try { return(MoveParser.ParseMove(moveString, board)); } catch (Exception ex) { if (ex is FormatException || ex is ArgumentException) { return(null); } throw; } }
public static void ParseMove_CorrectNotation_ReturnExpectedPromotion(string moveString, string expectedFromPositionString, string expectedToPositionString, char expectedPromotedPawn) { var pawn = _board[expectedFromPositionString]; Assert.That(pawn is Pawn); var expectedMove = new Promotion((Pawn)_board[expectedFromPositionString], PieceParser.ParsePiece(expectedPromotedPawn, pawn.Color), new Position(expectedToPositionString), _board); var move = MoveParser.ParseMove(moveString, _board); Assert.That(move is Promotion); var promotion = (Promotion)move; Assert.That(expectedMove.To == promotion.To); Assert.That(expectedMove.Piece == promotion.Piece); Assert.That(expectedMove.Board == promotion.Board); Assert.That(expectedMove.PromotedPawn.GetType() == promotion.PromotedPawn.GetType()); }
public void ParseMove_IncorrectMove_ThrowArgumentException(string moveString) { Assert.Throws <ArgumentException>(() => MoveParser.ParseMove(moveString, _board)); }
public void ParseMove_IncorrectNotation_ThrowFormatException(string moveString) { Assert.Throws <FormatException>(() => MoveParser.ParseMove(moveString, _board)); }
public void ParseMove_CorrectNotation_ConvertsBackToSameStringRepresentation(string moveString) { var move = MoveParser.ParseMove(moveString, _board); Assert.AreEqual(moveString, move.ToString()); }