コード例 #1
0
ファイル: GameUtilTest.java プロジェクト: ilinum/Chess
 @Test
 public void testPawnNonEmptyCell() {
   BoardWrapper b = new BoardWrapperImpl();
   CoordinatesImpl blackLoc = new CoordinatesImpl(3, 3);
   CoordinatesImpl whiteLoc = new CoordinatesImpl(3, 4);
   b.setPieceAt(blackLoc, Piece.createPiece(PieceColor.Black, PieceType.Pawn));
   b.setPieceAt(whiteLoc, Piece.createPiece(PieceColor.White, PieceType.Pawn));
   assertThat(new HashSet<>(), is(GameUtil.getAvailableMovesForPiece(whiteLoc, b.getInner())));
   assertThat(new HashSet<>(), is(GameUtil.getAvailableMovesForPiece(blackLoc, b.getInner())));
 }
コード例 #2
0
ファイル: GameUtilTest.java プロジェクト: ilinum/Chess
  @Test(timeout = 1000)
  public void testAvailableMovesAfterMove() {
    BoardWrapper b = new BoardWrapperImpl();

    Coordinates newPos = new CoordinatesImpl(0, BOARD_SIZE - 3);
    assertTrue(b.getPieceAt(newPos) instanceof EmptyCell);
    Piece knight = Piece.createPiece(PieceColor.White, PieceType.Knight);
    b.setPieceAt(newPos, knight);

    Coordinates initPos = new CoordinatesImpl(1, BOARD_SIZE - 1);
    Assert.assertEquals(knight, b.getPieceAt(initPos));
    b.setPieceAt(initPos, EmptyCell.INSTANCE);
    GameUtil.getAvailableMoves(PieceColor.White, b.getInner());
    GameUtil.getAvailableMoves(PieceColor.Black, b.getInner());
  }