-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestHero.java
63 lines (48 loc) · 1.27 KB
/
TestHero.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
class TestHero {
static Hero test;
@BeforeAll
static void setUpBeforeClass() throws Exception {
test = new Warrior();
}
@Test
void testSetCoords() {
test.setCoords(0, 1);
int x = test.getCoords()[0];
int y = test.getCoords()[1];
assertEquals(0,x);
assertEquals(1,y);
}
@Test
void testAddHP() {
int health = test.getHitPoints();
test.addHitPoints(25);
assertEquals(health + 25 , test.getHitPoints());
}
@Test
void testSubtractHP() {
int health = test.getHitPoints();
test.subtractHitPoints(50, new Skeleton());
//can heal
assertEquals(health - 50 , test.getHitPoints());
}
@Test
void testHealingPotion() {
int hp = test.getHitPoints();
assertEquals(test.getInventory()[0] , 0);
test.addHealthPotion();
assertEquals(test.getInventory()[0] , 1);
test.useHealthPotion();
assertEquals(test.getInventory()[0] , 0);
assertTrue(hp < test.getHitPoints());
}
@Test
void testVisionPotion() {
assertEquals(test.getInventory()[1] , 0);
test.addVisionPotion();
assertEquals(test.getInventory()[1] , 1);
assertTrue(test.useVisionPotion());
}
}