Ejemplo n.º 1
0
  /** Tests {@link PlayerFish#canMoveThroughWall()} using a dead EnemyFish. */
  @Test
  public void testCollideWithDeadEnemyFish() {
    EnemyFish ef = spy(new EnemyFish(mock(CollisionMask.class), null, 0.0, 0.0));
    when(ef.getBoundingArea().getSize()).thenReturn(5.1);
    ef.kill();

    pf.onCollide(ef);

    verify(pf, never()).kill();
  }
Ejemplo n.º 2
0
  /** Tests {@link PlayerFish#canMoveThroughWall()} using a smaller EnemyFish to collide with. */
  @Test
  public void testCollideWithSmallerEnemyFish() {
    EnemyFish ef = spy(new EnemyFish(mock(CollisionMask.class), null, 0.0, 0.0));
    when(ef.getBoundingArea().getSize()).thenReturn(3.9);
    ICollisionArea bb = pf.getBoundingArea();

    pf.onCollide(ef);

    verify(ef).kill();
    verify(pf, never()).kill();
    verify(bb).increaseSize(pf.getGrowthSpeed() * 3.9 / 5.0);
  }
Ejemplo n.º 3
0
  /**
   * Tests {@link PlayerFish#canMoveThroughWall()} using a larger EnemyFish to collide with, when
   * the player has multiple lives left.
   */
  @Test
  public void testCollideWithLargerEnemyFish2() {
    EnemyFish ef = spy(new EnemyFish(mock(CollisionMask.class), null, 0.0, 0.0));
    when(ef.getBoundingArea().getSize()).thenReturn(6.1);

    // Set the amount of lives to 2.
    pf.livesProperty().set(2);

    // Collide with an enemy
    pf.onCollide(ef);

    // The player should have one less life.
    assertEquals(1, pf.getLives());

    // The player should not be dead.
    assertFalse(pf.isDead());
    verify(ef, never()).kill();
  }