forked from Progether/JAdventure
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEntityTest.java
63 lines (50 loc) · 1.65 KB
/
EntityTest.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 java.util.ArrayList;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static junit.framework.Assert.assertTrue;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
@RunWith(JUnit4.class)
public class EntityTest {
private Entity entity;
@Before
public void setUp() {
entity = new Entity();
}
@After
public void tearDown() {
entity = null;
}
@Test
public void testCreation() {
assertThat(entity, instanceOf(Entity.class));
}
@Test
public void testReturnValues() {
assertThat(entity.getHealthCurrent(), instanceOf(int.class));
assertThat(entity.getArmour(), instanceOf(int.class));
assertThat(entity.getBackpack(), instanceOf(ArrayList.class));
assertThat(entity.getDamage(), instanceOf(double.class));
assertThat(entity.getGold(), instanceOf(int.class));
assertThat(entity.getName(), instanceOf(String.class));
assertThat(entity.getLevel(), instanceOf(int.class));
}
@Test
public void testSetters() {
entity.setHealthMax(50);
assertEquals(entity.getHealthMax(), 50);
assertTrue(entity.getHealthCurrent() <= entity.getHealthMax());
}
@Test
public void testBackpack() {
Item testItem = new Item(1);
ArrayList<Item> testArrayList = new ArrayList<Item>();
testArrayList.add(testItem);
entity.addBackpack(testItem);
assertEquals(entity.getBackpack(), testArrayList);
}
}