-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestDungeon.java
57 lines (48 loc) · 1.3 KB
/
TestDungeon.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
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
class TestDungeon {
static Dungeon test;
static Hero h;
@BeforeAll
static void setUpBeforeClass() throws Exception {
test = new Dungeon(7);
h = new Warrior();
}
@Test
void testDungeon() {
assertTrue(test.toString().contains("enterance"));
assertTrue(test.toString().contains("exit"));
assertTrue(test.toString().contains("pillar of OO"));
assertTrue(test.toString().contains("vision potion"));
assertTrue(test.toString().contains("healing potion"));
assertTrue(test.toString().contains("monster"));
}
@Test
void testMovement() {
int ex = test.getEntrance()[0];
int ey = test.getEntrance()[1];
h.setCoords(ex, ey);
int x = h.getCoords()[0];
int y = h.getCoords()[1];
if (x == 0) {
h.setCoords(x + 1, y);
assertEquals(x+1,h.getCoords()[0]);
}
if (x == 6) {
h.setCoords(x - 1, y);
assertEquals(x-1,h.getCoords()[0]);
}
if (y == 0) {
h.setCoords(x, y + 1);
assertEquals(y+1,h.getCoords()[1]);
}
if (y == 6) {
h.setCoords(x, y - 1);
assertEquals(y-1,h.getCoords()[1]);
}
h.setCoords(x, y);
assertEquals(x,h.getCoords()[0]);
assertEquals(y,h.getCoords()[1]);
}
}