Exemplo n.º 1
0
 @Test
 public void testCanAttackStraightDown() {
   Square currentSquare = new Square("d5");
   Square occupiedSquare = new Square("d1");
   board.placePiece(currentSquare, queen);
   board.placePiece(occupiedSquare, new Queen(Color.BLACK));
   assertTrue(queen.canAttack(board, currentSquare, occupiedSquare));
 }
Exemplo n.º 2
0
 @Test
 public void testCannotMoveToOccupiedSquare() {
   Square currentSquare = new Square("a1");
   Square occupiedSquare = new Square("b1");
   board.placePiece(currentSquare, queen);
   board.placePiece(occupiedSquare, new Queen(Color.WHITE));
   assertFalse(queen.canMove(board, currentSquare, occupiedSquare));
 }
Exemplo n.º 3
0
 @Test
 public void testCannotMoveWhenBlocked() {
   Square currentSquare = new Square("a1");
   Square emptySquare = new Square("c1");
   board.placePiece(currentSquare, queen);
   board.placePiece(new Square("b1"), new Queen(Color.WHITE));
   assertFalse(queen.canMove(board, currentSquare, emptySquare));
 }
Exemplo n.º 4
0
 @Test
 public void testCannotAttackNonStraightOrDiagonalSquare() {
   Square currentSquare = new Square("a1");
   Square occupiedSquare = new Square("b8");
   board.placePiece(currentSquare, queen);
   board.placePiece(occupiedSquare, new Queen(Color.BLACK));
   assertFalse(queen.canMove(board, currentSquare, occupiedSquare));
 }
Exemplo n.º 5
0
 @Test
 public void testCanAttackDiagonallyDownAndRight() {
   Square currentSquare = new Square("d5");
   Square occupiedSquare = new Square("f3");
   board.placePiece(currentSquare, queen);
   board.placePiece(occupiedSquare, new Queen(Color.BLACK));
   assertTrue(queen.canAttack(board, currentSquare, occupiedSquare));
 }
Exemplo n.º 6
0
 @Test
 public void testCannotAttackWhenBlocked() {
   Square currentSquare = new Square("a1");
   Square occupiedSquare = new Square("c1");
   board.placePiece(currentSquare, queen);
   board.placePiece(new Square("b1"), new Queen(Color.WHITE));
   board.placePiece(occupiedSquare, new Queen(Color.BLACK));
   assertFalse(queen.canAttack(board, currentSquare, occupiedSquare));
 }
Exemplo n.º 7
0
 @Test
 public void testCanMoveDiagonallyDownAndRight() {
   Square currentSquare = new Square("d5");
   Square emptySquare = new Square("f3");
   board.placePiece(currentSquare, queen);
   assertTrue(queen.canMove(board, currentSquare, emptySquare));
 }
Exemplo n.º 8
0
 @Test
 public void testCanMoveStraightRight() {
   Square currentSquare = new Square("d5");
   Square emptySquare = new Square("h5");
   board.placePiece(currentSquare, queen);
   assertTrue(queen.canMove(board, currentSquare, emptySquare));
 }
Exemplo n.º 9
0
 @Test
 public void testCannotAttackEmptySquare() {
   Square currentSquare = new Square("a1");
   Square emptySquare = new Square("c1");
   board.placePiece(currentSquare, queen);
   assertFalse(queen.canAttack(board, currentSquare, emptySquare));
 }
Exemplo n.º 10
0
 @Test
 public void testCannotAttackSameSquare() {
   Square currentSquare = new Square("a1");
   Square occupiedSquare = new Square("a1");
   board.placePiece(currentSquare, queen);
   assertFalse(queen.canAttack(board, currentSquare, occupiedSquare));
 }
Exemplo n.º 11
0
 @Test
 public void testCannotMoveToSameSquare() {
   Square currentSquare = new Square("a1");
   Square emptySquare = new Square("a1");
   board.placePiece(currentSquare, queen);
   assertFalse(queen.canMove(board, currentSquare, emptySquare));
 }
Exemplo n.º 12
0
 @Test
 public void testCannotMoveToNonStraightOrDiagonalSquare() {
   Square currentSquare = new Square("a1");
   Square emptySquare = new Square("b8");
   board.placePiece(currentSquare, queen);
   assertFalse(queen.canMove(board, currentSquare, emptySquare));
 }