-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameTest.java
More file actions
81 lines (71 loc) · 2.8 KB
/
GameTest.java
File metadata and controls
81 lines (71 loc) · 2.8 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import static org.junit.Assert.assertEquals;
import java.util.Vector;
import org.junit.Test;
public class GameTest {
String longDesc = "You are in a dark dingy cave. There is a large machine, a computer cluster, and the noise of the whirring fans fills the air. Whores, whores everywhere.";
String shortDesc = "A dark cave.";
String l1Name = "the Cave";
Location l1 = new Location(l1Name, longDesc, shortDesc);
String longDesc2 = "You are now in a forest. Dense with trees, you can barely see the sunlight through the leaves. Whores, whores everywhere.";
String shortDesc2 = "A dense forest.";
String l2Name = "the forest";
Location l2 = new Location(l2Name, longDesc2, shortDesc2);
Exit exit1 = new Exit(l2, Exit.EAST);
Exit exit2 = new Exit();
Vector<Exit> testing = new Vector<Exit>();
Vector<Item> testingItems = new Vector<Item>();
Player Dustan = new Player(l1);
Item cellphone = new Item("a cell phone", "a crapphy iFone", l2);
Container deskdrawer = new Container();
@Test
public void testLocation() {
l1.addExit(exit1);
testing.addElement(exit1);
l1.addItem(cellphone);
testingItems.addElement(cellphone);
assertEquals(l1.getItems(), testingItems);
assertEquals(l1.getExits(), testing);
assertEquals(l1.getDescription(), longDesc);
assertEquals(l1.getshortDescription(), shortDesc);
assertEquals(l2.getDescription(), longDesc2);
assertEquals(l2.getshortDescription(), shortDesc2);
//fail("Not yet implemented");
}
@Test
public void testExit(){
exit1.setCurrentLocation(l1);
assertEquals(Dustan.getLocation(), l1);
Dustan.takeExit(exit1);
assertEquals(Dustan.getLocation().toString(), l2.toString());
}
@Test
public void testItems() {
assertEquals(cellphone.getDescription(), "a crapphy iFone");
assertEquals(cellphone.getLocation(), l2);
assertEquals(cellphone.getName(), "a cell phone");
assertEquals(cellphone.isitintheInventory(), false);
Item carkeys = new Item("bunch of keys", "hmm, a bunch of keys. I wonder what they unlock.", l1, exit1);
exit1.setCurrentLocation(l1);
assertEquals(exit1.getIsItLocked(), true);
Dustan.takeExit(exit1);
assertEquals(Dustan.getLocation(), l1);
Dustan.addtoInventory(carkeys);
assertEquals(carkeys.isitintheInventory(), true);
Dustan.takeExit(exit1);
assertEquals(Dustan.getLocation(), l2);
}
@Test
public void testContainers() {
Container jewelrybox = new Container();
jewelrybox.setLocation(l2);
deskdrawer.addContainer(jewelrybox);
assertEquals(deskdrawer.getContainers(), new Vector<Container>());
jewelrybox.setLocation(l1);
deskdrawer.addContainer(jewelrybox);
assertEquals(deskdrawer.getContainers(), new Vector<Container>());
deskdrawer.setLocation(l1);
cellphone.putinContainer(deskdrawer);
assertEquals(deskdrawer.getItems(), new Vector<Item>());
assertEquals(cellphone.getLocation(), l2);
}
}