/** Tests the resetScore method that the score is 0. */
 @Test
 @SuppressWarnings("checkstyle:magicnumber")
 public final void testresetScore() {
   player.addScore(10);
   player.resetScore();
   Assert.assertEquals(0, player.getScore());
 }
 /** Test behavior of the getSpaceShip method for the player. */
 @Test
 @SuppressWarnings("checkstyle:magicnumber")
 public final void testGetSetSpaceShip() {
   SpaceShip ship = new SpaceShip(10.0, 10.0);
   player.setSpaceShip(ship);
   Assert.assertEquals(ship, player.getSpaceShip());
 }
 /** Tests the respawn method to load the spaceship in the middle again. */
 @Test
 @SuppressWarnings("checkstyle:magicnumber")
 public final void testRespawn() {
   player.getSpaceShip().setVelX(20);
   player.getSpaceShip().move(60.0);
   player.respawnShip();
   Assert.assertEquals(game.getCanvasWidth() / 2, player.getSpaceShip().getXCoor(), 0.05);
 }
 /** Test the add life method when the max is reached. */
 @Test
 @SuppressWarnings("checkstyle:magicnumber")
 public final void testMaxAddLife() {
   player.addLife();
   player.addLife();
   player.addLife();
   assertEquals(player.getLives(), 5);
 }
 /** Test the set active powerups method. */
 @Test
 public final void testSetActivePowerUps() {
   ArrayList<PowerUp> powerups = new ArrayList<PowerUp>();
   PowerUp powerup = new ShootPowerUp(player);
   powerups.add(powerup);
   player.setActivePowerUps(powerups);
   assertEquals(player.getActivePowerUps(), powerups);
 }
 /** Test if the fired bullet is from the player. */
 @Test
 @SuppressWarnings("checkstyle:magicnumber")
 public final void testShootBullet() {
   ArrayList<Bullet> list = player.getSpaceShip().shootBullet(5.0);
   ShipBullet bullet = (ShipBullet) list.get(0);
   System.out.println(player.getSpaceShip().getPlayer());
   assertEquals(bullet.getPlayer(), player);
 }
  /** Tests the die method for te player when it has only one live left. */
  @Test
  @SuppressWarnings("checkstyle:magicnumber")
  public final void testDieOutOfLives() {
    game.start();
    player.die();
    player.die();
    player.die();

    Assert.assertFalse(game.isInProgress());
  }
 /** Tests the die method for the player class when the player has more then 1 live left. */
 @Test
 @SuppressWarnings("checkstyle:magicnumber")
 public final void testDie() {
   player.die();
   Assert.assertEquals(2, player.getLives());
 }
 /**
  * Tests the behaviour of the addPoints method when adding a negative amount of points to the
  * players score.
  */
 @Test
 @SuppressWarnings("checkstyle:magicnumber")
 public final void testAddNegativeScore() {
   player.addScore(-10);
   Assert.assertEquals(-10, player.getScore());
 }
Exemplo n.º 10
0
 /** Test behaviour of the getScore method for the player class. */
 @Test
 @SuppressWarnings("checkstyle:magicnumber")
 public final void testGetScore() {
   Assert.assertEquals(0, player.getScore());
 }
Exemplo n.º 11
0
 /** Test the add life method. */
 @Test
 public final void testAddLife() {
   int lives = player.getLives();
   player.addLife();
   assertEquals(player.getLives(), lives + 1);
 }