@Test
 public void knightMovementDownLeftTwoCols() {
   game = new Chess();
   Knight knight = new Knight(PColor.Black);
   game.setPieceAt(4, 4, knight);
   assertTrue(game.checkMove(4, 4, 5, 2, knight));
 }
 @Test
 public void knightInvalidMovePatternTooFewCols2() {
   game = new Chess();
   Knight knight = new Knight(PColor.Black);
   game.setPieceAt(4, 4, knight);
   assertFalse(game.checkMove(4, 4, 3, 4, knight));
 }
 @Test
 public void knightMovementUpRightOneCol() {
   game = new Chess();
   Knight knight = new Knight(PColor.Black);
   game.setPieceAt(4, 4, knight);
   assertTrue(game.checkMove(4, 4, 2, 5, knight));
 }
 @Test
 public void bishopMovementDownLeft() {
   game = new Chess();
   Bishop bishop = new Bishop(PColor.Black);
   game.setPieceAt(2, 5, bishop);
   assertTrue(game.checkMove(2, 5, 5, 2, bishop));
 }
 @Test
 public void bishopInvalidMovement() {
   game = new Chess();
   Bishop bishop = new Bishop(PColor.Black);
   game.setPieceAt(5, 5, bishop);
   assertFalse(game.checkMove(5, 5, 5, 2, bishop));
 }
 @Test
 public void knightCanCapture() {
   game = new Chess();
   Knight knight = new Knight(PColor.Black);
   game.setPieceAt(4, 4, knight);
   game.setPieceAt(2, 3, whitePawn);
   assertTrue(game.checkMove(4, 4, 2, 3, knight));
 }
 @Test
 public void knightCantMoveToSameColorPieceWhite() {
   game = new Chess();
   Knight knight = new Knight(PColor.White);
   game.setPieceAt(4, 4, knight);
   game.setPieceAt(2, 3, whitePawn);
   assertFalse(game.checkMove(4, 4, 2, 3, knight));
 }
 @Test
 public void bishopMovementDownRightSameColorInPlace() {
   game = new Chess();
   Bishop bishop = new Bishop(PColor.Black);
   game.setPieceAt(2, 1, bishop);
   game.setPieceAt(5, 4, blackPawn);
   assertFalse(game.checkMove(2, 1, 5, 4, bishop));
 }
 @Test
 public void bishopMovementDownRightPieceBlocking() {
   game = new Chess();
   Bishop bishop = new Bishop(PColor.Black);
   game.setPieceAt(2, 1, bishop);
   game.setPieceAt(4, 3, whitePawn);
   assertFalse(game.checkMove(2, 1, 5, 4, bishop));
 }
 @Test
 public void bishopMovementUpRightPieceBlocking() {
   game = new Chess();
   Bishop bishop = new Bishop(PColor.Black);
   game.setPieceAt(5, 2, bishop);
   game.setPieceAt(3, 4, whitePawn);
   assertFalse(game.checkMove(5, 2, 2, 5, bishop));
 }
 @Test
 public void checkWhiteKnightsPosition() {
   // White Knights are at row 7, col 1 and 6
   game = new Chess();
   boolean isLeftKnight = game.getPieceAt(7, 1) instanceof Knight;
   boolean isRightKnight = game.getPieceAt(7, 6) instanceof Knight;
   boolean isLeftWhite = game.getPieceAt(7, 1).getColor() == PColor.White;
   boolean isRightWhite = game.getPieceAt(7, 6).getColor() == PColor.White;
   assertTrue(isLeftKnight && isRightKnight && isLeftWhite && isRightWhite);
 }
 @Test
 public void checkBlackBishopsPositions() {
   // Black Bishops are at row 0, col 2 and 5
   game = new Chess();
   boolean isLeftBishop = game.getPieceAt(0, 2) instanceof Bishop;
   boolean isRightBishop = game.getPieceAt(0, 5) instanceof Bishop;
   boolean isLeftBlack = game.getPieceAt(0, 2).getColor() == PColor.Black;
   boolean isRightBlack = game.getPieceAt(0, 5).getColor() == PColor.Black;
   assertTrue(isLeftBishop && isRightBishop && isLeftBlack && isRightBlack);
 }
 @Test
 public void checkWhiteBishopsPosition() {
   // White Bishops are at row 7, col 2 and 5
   game = new Chess();
   boolean isLeftBishop = game.getPieceAt(7, 2) instanceof Bishop;
   boolean isRightBishop = game.getPieceAt(7, 5) instanceof Bishop;
   boolean isLeftWhite = game.getPieceAt(7, 2).getColor() == PColor.White;
   boolean isRightWhite = game.getPieceAt(7, 5).getColor() == PColor.White;
   assertTrue(isLeftBishop && isRightBishop && isLeftWhite && isRightWhite);
 }
  @Test
  public void checkBlackKnightsPositions() {
    // Black Knights are at row 0, col 1 and 6
    game = new Chess();
    boolean isLeftKnight = game.getPieceAt(0, 1) instanceof Knight;
    boolean isRightKnight = game.getPieceAt(0, 6) instanceof Knight;
    boolean isLeftBlack = game.getPieceAt(0, 1).getColor() == PColor.Black;
    boolean isRightBlack = game.getPieceAt(0, 6).getColor() == PColor.Black;

    assertTrue(isLeftKnight && isRightKnight && isLeftBlack && isRightBlack);
  }
/** @author andy */
public class KnightTester {

  Chess game = new Chess();
  Board boardTest = new Board();

  Pawn whitePawn = (Pawn) game.getPieceAt(6, 1);
  Pawn blackPawn = (Pawn) game.getPieceAt(1, 1);

  @Test
  public void checkWhiteKnightsPosition() {
    // White Knights are at row 7, col 1 and 6
    game = new Chess();
    boolean isLeftKnight = game.getPieceAt(7, 1) instanceof Knight;
    boolean isRightKnight = game.getPieceAt(7, 6) instanceof Knight;
    boolean isLeftWhite = game.getPieceAt(7, 1).getColor() == PColor.White;
    boolean isRightWhite = game.getPieceAt(7, 6).getColor() == PColor.White;
    assertTrue(isLeftKnight && isRightKnight && isLeftWhite && isRightWhite);
  }

  @Test
  public void checkBlackKnightsPositions() {
    // Black Knights are at row 0, col 1 and 6
    game = new Chess();
    boolean isLeftKnight = game.getPieceAt(0, 1) instanceof Knight;
    boolean isRightKnight = game.getPieceAt(0, 6) instanceof Knight;
    boolean isLeftBlack = game.getPieceAt(0, 1).getColor() == PColor.Black;
    boolean isRightBlack = game.getPieceAt(0, 6).getColor() == PColor.Black;

    assertTrue(isLeftKnight && isRightKnight && isLeftBlack && isRightBlack);
  }

  @Test
  public void knightMovementUpLeftTwoCols() {
    game = new Chess();
    Knight knight = new Knight(PColor.Black);
    game.setPieceAt(4, 4, knight);
    assertTrue(game.checkMove(4, 4, 3, 2, knight));
  }

  @Test
  public void knightMovementUpLeftOneCol() {
    game = new Chess();
    Knight knight = new Knight(PColor.Black);
    game.setPieceAt(4, 4, knight);
    assertTrue(game.checkMove(4, 4, 2, 3, knight));
  }

  @Test
  public void knightMovementUpRightTwoCols() {
    game = new Chess();
    Knight knight = new Knight(PColor.Black);
    game.setPieceAt(4, 4, knight);
    assertTrue(game.checkMove(4, 4, 3, 6, knight));
  }

  @Test
  public void knightMovementUpRightOneCol() {
    game = new Chess();
    Knight knight = new Knight(PColor.Black);
    game.setPieceAt(4, 4, knight);
    assertTrue(game.checkMove(4, 4, 2, 5, knight));
  }

  @Test
  public void knightMovementDownRightTwoCols() {
    game = new Chess();
    Knight knight = new Knight(PColor.Black);
    game.setPieceAt(4, 4, knight);
    assertTrue(game.checkMove(4, 4, 5, 6, knight));
  }

  @Test
  public void knightMovementDownRightOneCol() {
    game = new Chess();
    Knight knight = new Knight(PColor.Black);
    game.setPieceAt(4, 4, knight);
    assertTrue(game.checkMove(4, 4, 6, 5, knight));
  }

  @Test
  public void knightMovementDownLeftTwoCols() {
    game = new Chess();
    Knight knight = new Knight(PColor.Black);
    game.setPieceAt(4, 4, knight);
    assertTrue(game.checkMove(4, 4, 5, 2, knight));
  }

  @Test
  public void knightMovementDownLeftOneCol() {
    game = new Chess();
    Knight knight = new Knight(PColor.Black);
    game.setPieceAt(4, 4, knight);
    assertTrue(game.checkMove(4, 4, 6, 3, knight));
  }

  @Test
  public void knightCantMoveToSameColorPieceBlack() {
    game = new Chess();
    Knight knight = new Knight(PColor.Black);
    game.setPieceAt(4, 4, knight);
    game.setPieceAt(2, 3, blackPawn);
    assertFalse(game.checkMove(4, 4, 2, 3, knight));
  }

  @Test
  public void knightCantMoveToSameColorPieceWhite() {
    game = new Chess();
    Knight knight = new Knight(PColor.White);
    game.setPieceAt(4, 4, knight);
    game.setPieceAt(2, 3, whitePawn);
    assertFalse(game.checkMove(4, 4, 2, 3, knight));
  }

  @Test
  public void knightCanCapture() {
    game = new Chess();
    Knight knight = new Knight(PColor.Black);
    game.setPieceAt(4, 4, knight);
    game.setPieceAt(2, 3, whitePawn);
    assertTrue(game.checkMove(4, 4, 2, 3, knight));
  }

  @Test
  public void knightInvalidMovePatternTooManyRows() {
    game = new Chess();
    Knight knight = new Knight(PColor.Black);
    game.setPieceAt(4, 4, knight);
    assertFalse(game.checkMove(4, 4, 7, 3, knight));
  }

  @Test
  public void knightInvalidMovePatternTooManyCols() {
    game = new Chess();
    Knight knight = new Knight(PColor.Black);
    game.setPieceAt(4, 4, knight);
    assertFalse(game.checkMove(4, 4, 2, 1, knight));
  }

  @Test
  public void knightInvalidMovePatternTooFewRows() {
    game = new Chess();
    Knight knight = new Knight(PColor.Black);
    game.setPieceAt(4, 4, knight);
    assertFalse(game.checkMove(4, 4, 4, 2, knight));
  }

  @Test
  public void knightInvalidMovePatternTooFewCols() {
    game = new Chess();
    Knight knight = new Knight(PColor.Black);
    game.setPieceAt(4, 4, knight);
    assertFalse(game.checkMove(4, 4, 2, 4, knight));
  }

  @Test
  public void knightInvalidMovePatternTooFewCols2() {
    game = new Chess();
    Knight knight = new Knight(PColor.Black);
    game.setPieceAt(4, 4, knight);
    assertFalse(game.checkMove(4, 4, 3, 4, knight));
  }
}
/** @author andy */
public class BishopTester {

  Chess game = new Chess();
  Board boardTest = new Board();

  Pawn whitePawn = (Pawn) game.getPieceAt(6, 1);
  Pawn blackPawn = (Pawn) game.getPieceAt(1, 1);

  @Test
  public void checkWhiteBishopsPosition() {
    // White Bishops are at row 7, col 2 and 5
    game = new Chess();
    boolean isLeftBishop = game.getPieceAt(7, 2) instanceof Bishop;
    boolean isRightBishop = game.getPieceAt(7, 5) instanceof Bishop;
    boolean isLeftWhite = game.getPieceAt(7, 2).getColor() == PColor.White;
    boolean isRightWhite = game.getPieceAt(7, 5).getColor() == PColor.White;
    assertTrue(isLeftBishop && isRightBishop && isLeftWhite && isRightWhite);
  }

  @Test
  public void checkBlackBishopsPositions() {
    // Black Bishops are at row 0, col 2 and 5
    game = new Chess();
    boolean isLeftBishop = game.getPieceAt(0, 2) instanceof Bishop;
    boolean isRightBishop = game.getPieceAt(0, 5) instanceof Bishop;
    boolean isLeftBlack = game.getPieceAt(0, 2).getColor() == PColor.Black;
    boolean isRightBlack = game.getPieceAt(0, 5).getColor() == PColor.Black;
    assertTrue(isLeftBishop && isRightBishop && isLeftBlack && isRightBlack);
  }

  @Test
  public void bishopMovementUpRight() {
    game = new Chess();
    Bishop bishop = new Bishop(PColor.Black);
    game.setPieceAt(5, 2, bishop);
    assertTrue(game.checkMove(5, 2, 2, 5, bishop));
  }

  @Test
  public void bishopMovementUpRightPieceBlocking() {
    game = new Chess();
    Bishop bishop = new Bishop(PColor.Black);
    game.setPieceAt(5, 2, bishop);
    game.setPieceAt(3, 4, whitePawn);
    assertFalse(game.checkMove(5, 2, 2, 5, bishop));
  }

  @Test
  public void bishopMovementUpRightSameColorInPlace() {
    game = new Chess();
    Bishop bishop = new Bishop(PColor.Black);
    game.setPieceAt(5, 2, bishop);
    game.setPieceAt(2, 5, blackPawn);
    assertFalse(game.checkMove(5, 2, 2, 5, bishop));
  }

  @Test
  public void bishopMovementDownRight() {
    game = new Chess();
    Bishop bishop = new Bishop(PColor.Black);
    game.setPieceAt(2, 1, bishop);
    assertTrue(game.checkMove(2, 1, 5, 4, bishop));
  }

  @Test
  public void bishopMovementDownRightPieceBlocking() {
    game = new Chess();
    Bishop bishop = new Bishop(PColor.Black);
    game.setPieceAt(2, 1, bishop);
    game.setPieceAt(4, 3, whitePawn);
    assertFalse(game.checkMove(2, 1, 5, 4, bishop));
  }

  @Test
  public void bishopMovementDownRightSameColorInPlace() {
    game = new Chess();
    Bishop bishop = new Bishop(PColor.Black);
    game.setPieceAt(2, 1, bishop);
    game.setPieceAt(5, 4, blackPawn);
    assertFalse(game.checkMove(2, 1, 5, 4, bishop));
  }

  @Test
  public void bishopMovementDownLeft() {
    game = new Chess();
    Bishop bishop = new Bishop(PColor.Black);
    game.setPieceAt(2, 5, bishop);
    assertTrue(game.checkMove(2, 5, 5, 2, bishop));
  }

  @Test
  public void bishopMovementDownLeftPieceBlocking() {
    game = new Chess();
    Bishop bishop = new Bishop(PColor.Black);
    game.setPieceAt(2, 5, bishop);
    game.setPieceAt(4, 3, whitePawn);
    assertFalse(game.checkMove(2, 5, 5, 2, bishop));
  }

  @Test
  public void bishopMovementDownLeftSameColorInPlace() {
    game = new Chess();
    Bishop bishop = new Bishop(PColor.Black);
    game.setPieceAt(2, 5, bishop);
    game.setPieceAt(5, 2, blackPawn);
    assertFalse(game.checkMove(2, 5, 5, 2, bishop));
  }

  @Test
  public void bishopMovementUpLeft() {
    game = new Chess();
    Bishop bishop = new Bishop(PColor.Black);
    game.setPieceAt(5, 5, bishop);
    assertTrue(game.checkMove(5, 5, 2, 2, bishop));
  }

  @Test
  public void bishopMovementUpLeftPieceBlocking() {
    game = new Chess();
    Bishop bishop = new Bishop(PColor.Black);
    game.setPieceAt(5, 5, bishop);
    game.setPieceAt(4, 4, whitePawn);
    assertFalse(game.checkMove(5, 5, 2, 2, bishop));
  }

  @Test
  public void bishopMovementUpLeftSameColorInPlace() {
    game = new Chess();
    Bishop bishop = new Bishop(PColor.Black);
    game.setPieceAt(5, 5, bishop);
    game.setPieceAt(2, 2, blackPawn);
    assertFalse(game.checkMove(5, 5, 2, 2, bishop));
  }

  @Test
  public void bishopInvalidMovement() {
    game = new Chess();
    Bishop bishop = new Bishop(PColor.Black);
    game.setPieceAt(5, 5, bishop);
    assertFalse(game.checkMove(5, 5, 5, 2, bishop));
  }
}