Coverage Summary for Class: MonsterTest (io.team9.game.tests.Entitys)
| Class | Class, % | Method, % | Line, % |
|---|---|---|---|
| MonsterTest | 100% (1/1) | 100% (3/3) | 100% (27/27) |
1 package io.team9.game.tests.Entitys; 2 3 import com.badlogic.gdx.math.Vector2; 4 import com.mygdx.game.Components.Pirate; 5 import com.mygdx.game.Entitys.*; 6 import com.mygdx.game.Managers.GameManager; 7 import com.mygdx.game.Managers.PhysicsManager; 8 import com.mygdx.game.Physics.CollisionInfo; 9 import io.team9.game.tests.GdxTestRunner; 10 import org.junit.Test; 11 import org.junit.runner.RunWith; 12 13 import static org.junit.Assert.*; 14 15 @RunWith(GdxTestRunner.class) 16 public class MonsterTest { 17 @Test 18 public void deathTest(){ 19 PhysicsManager.Initialize(); 20 21 Monster monster = new Monster(); 22 monster.setHealth(0); 23 assertFalse(monster.isAlive()); 24 monster.setHealth(1); 25 assertTrue(monster.isAlive()); 26 } 27 @Test 28 public void cannonballCollisionTest(){ 29 PhysicsManager.Initialize(); 30 GameManager.Initialize(); 31 Ship shooter = new Ship(); 32 shooter.setFaction(1); 33 34 Monster hit = new Monster(); 35 CannonBall shot = new CannonBall(); 36 CollisionInfo info = new CollisionInfo(); 37 Vector2 blank = new Vector2(); 38 39 shot.fire(blank,blank,shooter); 40 info.b= hit; 41 info.a=shot; 42 Integer healthBefore = hit.getHealth(); 43 hit.EnterTrigger(info); 44 assertEquals("After being hit the health should be 5 less than before",healthBefore-5,hit.getHealth()); 45 46 47 hit.setHealth(5); 48 shooter.setFaction(1); 49 hit.EnterTrigger(info); 50 assertEquals(200,shooter.getPlunder()); 51 assertEquals(100,shooter.getComponent(Pirate.class).getPoints()); 52 assertFalse(hit.isAlive()); 53 } 54 }