content: package com.chess.tests;
  
  import com.chess.engine.board.Board;
  import com.chess.engine.board.BoardUtils;
  import com.chess.engine.board.Move;
  import com.chess.engine.board.Move.MoveFactory;
  import com.chess.engine.board.MoveTransition;
  import com.chess.engine.player.ai.StandardBoardEvaluator;
  import com.chess.pgn.FenUtilities;
  import org.junit.Test;
  
  import static org.junit.Assert.*;
  
  public class TestPlayer {
  
      @Test
      public void testSimpleEvaluation() {
          final Board board = Board.createStandardBoard();
          final MoveTransition t1 = board.currentPlayer()
                  .makeMove(MoveFactory.createMove(board, BoardUtils.INSTANCE.getCoordinateAtPosition("e2"),
                                  BoardUtils.INSTANCE.getCoordinateAtPosition("e4")));
          assertTrue(t1.getMoveStatus().isDone());
          final MoveTransition t2 = t1.getToBoard()
                  .currentPlayer()
                  .makeMove(MoveFactory.createMove(t1.getToBoard(), BoardUtils.INSTANCE.getCoordinateAtPosition("e7"),
                          BoardUtils.INSTANCE.getCoordinateAtPosition("e5")));
          assertTrue(t2.getMoveStatus().isDone());
          assertEquals(0, StandardBoardEvaluator.get().evaluate(t2.getToBoard(), 0));
      }
  
      @Test
      public void testBug() {
          final Board board = Board.createStandardBoard();
          final MoveTransition t1 = board.currentPlayer()
                  .makeMove(MoveFactory.createMove(board, BoardUtils.INSTANCE.getCoordinateAtPosition("c2"),
                                  BoardUtils.INSTANCE.getCoordinateAtPosition("c3")));
          assertTrue(t1.getMoveStatus().isDone());
          final MoveTransition t2 = t1.getToBoard()
                  .currentPlayer()
                  .makeMove(MoveFactory.createMove(t1.getToBoard(), BoardUtils.INSTANCE.getCoordinateAtPosition("b8"),
                          BoardUtils.INSTANCE.getCoordinateAtPosition("a6")));
          assertTrue(t2.getMoveStatus().isDone());
          final MoveTransition t3 = t2.getToBoard()
                  .currentPlayer()
                  .makeMove(MoveFactory.createMove(t2.getToBoard(), BoardUtils.INSTANCE.getCoordinateAtPosition("d1"),
                          BoardUtils.INSTANCE.getCoordinateAtPosition("a4")));
          assertTrue(t3.getMoveStatus().isDone());
          final MoveTransition t4 = t3.getToBoard()
                  .currentPlayer()
                  .makeMove(MoveFactory.createMove(t3.getToBoard(), BoardUtils.INSTANCE.getCoordinateAtPosition("d7"),
                          BoardUtils.INSTANCE.getCoordinateAtPosition("d6")));
          assertFalse(t4.getMoveStatus().isDone());
      }
  
      @Test
      public void testDiscoveredCheck() {
          final Board board = FenUtilities.createGameFromFEN("4k3/8/8/r7/8/4B3/4R3/2K5 w - - 0 1");
          System.out.println(FenUtilities.createFENFromGame(board));
          final MoveTransition t1 = board.currentPlayer()
                  .makeMove(MoveFactory.createMove(board, BoardUtils.INSTANCE.getCoordinateAtPosition("e3"),
                                  BoardUtils.INSTANCE.getCoordinateAtPosition("b6")));
          assertTrue(t1.getMoveStatus().isDone());
          assertTrue(t1.getToBoard().currentPlayer().isInCheck());
          final MoveTransition t2 = t1.getToBoard()
                  .currentPlayer()
                  .makeMove(MoveFactory.createMove(t1.getToBoard(), BoardUtils.INSTANCE.getCoordinateAtPosition("a5"),
                          BoardUtils.INSTANCE.getCoordinateAtPosition("b5")));
          assertFalse(t2.getMoveStatus().isDone());
          final MoveTransition t3 = t1.getToBoard()
                  .currentPlayer()
                  .makeMove(MoveFactory.createMove(t1.getToBoard(), BoardUtils.INSTANCE.getCoordinateAtPosition("a5"),
                          BoardUtils.INSTANCE.getCoordinateAtPosition("e5")));
          assertTrue(t3.getMoveStatus().isDone());
      }
  
      @Test
      public void testUnmakeMove() {
          final Board board = Board.createStandardBoard();
          final Move m1 = MoveFactory.createMove(board, BoardUtils.INSTANCE.getCoordinateAtPosition("e2"),
                  BoardUtils.INSTANCE.getCoordinateAtPosition("e4"));
          final MoveTransition t1 = board.currentPlayer()
                  .makeMove(m1);
          assertTrue(t1.getMoveStatus().isDone());
          t1.getToBoard().currentPlayer().getOpponent().unMakeMove(m1);
      }
  
      @Test
      public void testIllegalMove() {
          final Board board = Board.createStandardBoard();
          final Move m1 = MoveFactory.createMove(board, BoardUtils.INSTANCE.getCoordinateAtPosition("e2"),
                  BoardUtils.INSTANCE.getCoordinateAtPosition("e6"));
          final MoveTransition t1 = board.currentPlayer()
                  .makeMove(m1);
          assertFalse(t1.getMoveStatus().isDone());
      }
  
  }
  