Esempio n. 1
0
  /**
   * Tests the deleteVertical method, by making a nice board with vertical combinations of 5,4 and 3
   * Gems and checking if the method finds those combinations.
   */
  @Test
  public final void testDeleteVertical() {
    board = new Board(5, 0, 0, false);
    gems = board.getGems();
    for (int col = 0; col < 5; col++) {
      for (int row = 0; row < 5 - col; row++) {
        gems[row][col].setType(1);
      }
    }
    gems[4][1].setType(2);
    gems[3][2].setType(2);
    gems[4][2].setType(2);
    ArrayList<Gem> array1 = new ArrayList<Gem>();
    array1.add(gems[1][0]);
    array1.add(gems[2][0]);
    array1.add(gems[3][0]);
    array1.add(gems[4][0]);
    ArrayList<Gem> array2 = board.deleteVertical(gems[0][0]);
    assertEquals(array1, array2);

    ArrayList<Gem> array3 = new ArrayList<Gem>();
    array3.add(gems[1][1]);
    array3.add(gems[0][1]);
    array3.add(gems[3][1]);
    ArrayList<Gem> array4 = board.deleteVertical(gems[2][1]);
    assertEquals(array3, array4);

    ArrayList<Gem> array5 = new ArrayList<Gem>();
    array5.add(gems[0][2]);
    array5.add(gems[2][2]);
    ArrayList<Gem> array6 = board.deleteVertical(gems[1][2]);
    assertEquals(array5, array6);
  }