public void Whether_Board_UpdatesPositionOnBoard_On_MoveTo() { var board = new Board(); var originalPosition = new Square(5, 4); var newPosition = new Square(4, 3); var bishop = new Bishop(originalPosition, board, PieceColor.White); var possibleMoves = bishop.MoveTo(newPosition); Assert.That(board.Squares[originalPosition] == null); Assert.That(board.Squares[newPosition] == bishop); }
public void MoveTo_should_set_square_to_target_square() { // Arrange const string currentSquare = "f1"; const string targetSquare = "c4"; ChessmenBase bishop = new Bishop(Color.Black, currentSquare); // Act bishop.MoveTo(targetSquare); // Assert Assert.That(bishop.Square, Is.EqualTo(targetSquare)); }
public void MoveTo_should_ignore_squares_that_are_not_allowed() { // Arrange const string currentSquare = "f1"; const string targetSquare = "g8"; ChessmenBase bishop = new Bishop(Color.Black, currentSquare); // Act bishop.MoveTo(targetSquare); // Assert Assert.That(bishop.Square, Is.EqualTo(currentSquare)); }
public void Whether_Board_InvokesOnPieceMoved_On_PieceMoveTo() { var board = new Board(); var pieceMoved = false; board.PieceMoved += (b, m) => pieceMoved = true; var originalPosition = new Square(5, 4); var newPosition = new Square(4, 3); var bishop = new Bishop(originalPosition, board, PieceColor.White); bishop.MoveTo(newPosition); Assert.That(pieceMoved); }
public void Whether_Board_InvokesPieceTaken_On_Caprute() { var board = new Board(); var pieceTaken = false; var originalPosition = new Square(5, 4); var newPosition = new Square(4, 3); var bishop = new Bishop(originalPosition, board, PieceColor.White); var knight = new Bishop(newPosition, board, PieceColor.Black); knight.PieceTaken += (s) => pieceTaken = true; var possibleMoves = bishop.MoveTo(newPosition); Assert.That(board.Squares[originalPosition] == null); Assert.That(board.Squares[newPosition] == bishop); Assert.That(pieceTaken); }