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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
|
namespace MundusTests.ServiceTests.Tiles.Mobs
{
using Mundus.Service.Tiles.Items.Types;
using Mundus.Service.Tiles.Mobs;
using NUnit.Framework;
[TestFixture]
public static class InventoryTests
{
[Test]
[TestCase("one", "two")]
[TestCase(null, "two")]
[TestCase("", "two")]
public static void AddsToHotbar(string stock_id1, string stock_id2)
{
Inventory inv = new Inventory(5);
inv.AddToHotbar(new Material(stock_id1), 2);
inv.AddToHotbar(new Material(stock_id2), 4);
Assert.AreEqual(stock_id1, inv.Hotbar[2].stock_id, "Add to hotbar doesn't work as expected");
Assert.AreEqual(stock_id2, inv.Hotbar[4].stock_id, "Add to hotbar doesn't work as expected");
}
[Test]
[TestCase("one", "two")]
[TestCase(null, "two")]
[TestCase("", "two")]
public static void AddsToItems(string stock_id1, string stock_id2)
{
Inventory inv = new Inventory(5);
inv.AddToItems(new Material(stock_id1), 2);
inv.AddToItems(new Material(stock_id2), 4);
Assert.AreEqual(stock_id1, inv.Items[2].stock_id, "Add to items doesn't work as expected");
Assert.AreEqual(stock_id2, inv.Items[4].stock_id, "Add to items doesn't work as expected");
}
[Test]
[TestCase("one", "two")]
[TestCase(null, "two")]
[TestCase("", "two")]
public static void AddsToAccessories(string stock_id1, string stock_id2)
{
Inventory inv = new Inventory(5);
inv.AddToAccessories(new Gear(stock_id1), 2);
inv.AddToAccessories(new Gear(stock_id2), 4);
Assert.AreEqual(stock_id1, inv.Accessories[2].stock_id, "Add to accessories doesn't work as expected");
Assert.AreEqual(stock_id2, inv.Accessories[4].stock_id, "Add to accessories doesn't work as expected");
}
[Test]
[TestCase("one", "two")]
[TestCase(null, "two")]
[TestCase("", "two")]
public static void AddsToGear(string stock_id1, string stock_id2)
{
Inventory inv = new Inventory(5);
inv.AddToGear(new Gear(stock_id1), 2);
inv.AddToGear(new Gear(stock_id2), 4);
Assert.AreEqual(stock_id1, inv.Gear[2].stock_id, "Add to gear doesn't work as expected");
Assert.AreEqual(stock_id2, inv.Gear[4].stock_id, "Add to gear doesn't work as expected");
}
[Test]
[TestCase("one", "two")]
[TestCase(null, "two")]
[TestCase("", "two")]
public static void AppendsToHotbar(string stock_id1, string stock_id2)
{
Inventory inv = new Inventory(5);
inv.AppendToHotbar(new Material(stock_id1));
inv.AppendToHotbar(new Material(stock_id2));
Assert.AreEqual(stock_id1, inv.Hotbar[0].stock_id, "Append to hotbar doesn't work as expected");
Assert.AreEqual(stock_id2, inv.Hotbar[1].stock_id, "Append to hotbar doesn't work as expected");
}
[Test]
[TestCase("one", "two")]
[TestCase(null, "two")]
[TestCase("", "two")]
public static void AppendsToItems(string stock_id1, string stock_id2)
{
Inventory inv = new Inventory(5);
inv.AppendToItems(new Material(stock_id1));
inv.AppendToItems(new Material(stock_id2));
Assert.AreEqual(stock_id1, inv.Items[0].stock_id, "Append to items doesn't work as expected");
Assert.AreEqual(stock_id2, inv.Items[1].stock_id, "Append to items doesn't work as expected");
}
[Test]
[TestCase("one", "two")]
[TestCase(null, "two")]
[TestCase("", "two")]
public static void AppendsToAccessories(string stock_id1, string stock_id2)
{
Inventory inv = new Inventory(5);
inv.AppendToAccessories(new Gear(stock_id1));
inv.AppendToAccessories(new Gear(stock_id2));
Assert.AreEqual(stock_id1, inv.Accessories[0].stock_id, "Append to accessories doesn't work as expected");
Assert.AreEqual(stock_id2, inv.Accessories[1].stock_id, "Append to accessories doesn't work as expected");
}
[Test]
[TestCase("one", "two")]
[TestCase(null, "two")]
[TestCase("", "two")]
public static void AppendsToGear(string stock_id1, string stock_id2)
{
Inventory inv = new Inventory(5);
inv.AppendToGear(new Gear(stock_id1));
inv.AppendToGear(new Gear(stock_id2));
Assert.AreEqual(stock_id1, inv.Gear[0].stock_id, "Append to gear doesn't work as expected");
Assert.AreEqual(stock_id2, inv.Gear[1].stock_id, "Append to gear doesn't work as expected");
}
[Test]
[TestCase("one", "two")]
[TestCase(null, "two")]
[TestCase("", "two")]
public static void DeletesFromHotbar(string stock_id1, string stock_id2)
{
Inventory inv = new Inventory(5);
inv.AddToHotbar(new Gear(stock_id1), 2);
inv.AddToHotbar(new Gear(stock_id2), 4);
inv.DeleteFromHotbar(2);
inv.DeleteFromHotbar(4);
Assert.IsNull(inv.Hotbar[2], "Doesn't delete item properly from hotbar");
Assert.IsNull(inv.Hotbar[4], "Doesn't delete item properly from hotbar");
}
[Test]
[TestCase("one", "two")]
[TestCase(null, "two")]
[TestCase("", "two")]
public static void DeletesFromItems(string stock_id1, string stock_id2)
{
Inventory inv = new Inventory(5);
inv.AddToItems(new Gear(stock_id1), 2);
inv.AddToItems(new Gear(stock_id2), 4);
inv.DeleteFromItems(2);
inv.DeleteFromItems(4);
Assert.IsNull(inv.Items[2], "Doesn't delete item properly from items");
Assert.IsNull(inv.Items[4], "Doesn't delete item properly from items");
}
[Test]
[TestCase("one", "two")]
[TestCase(null, "two")]
[TestCase("", "two")]
public static void DeletesFromAccessories(string stock_id1, string stock_id2)
{
Inventory inv = new Inventory(5);
inv.AddToAccessories(new Gear(stock_id1), 2);
inv.AddToAccessories(new Gear(stock_id2), 4);
inv.DeleteFromAccessories(2);
inv.DeleteFromAccessories(4);
Assert.IsNull(inv.Accessories[2], "Doesn't delete item properly from accessories");
Assert.IsNull(inv.Accessories[4], "Doesn't delete item properly from accessories");
}
[Test]
[TestCase("one", "two")]
[TestCase(null, "two")]
[TestCase("", "two")]
public static void DeletesFromGear(string stock_id1, string stock_id2)
{
Inventory inv = new Inventory(5);
inv.AddToGear(new Gear(stock_id1), 2);
inv.AddToGear(new Gear(stock_id2), 4);
inv.DeleteFromGear(2);
inv.DeleteFromGear(4);
Assert.IsNull(inv.Gear[2], "Doesn't delete item properly from gear");
Assert.IsNull(inv.Gear[4], "Doesn't delete item properly from gear");
}
[Test]
[TestCase(1)]
[TestCase(5)]
[TestCase(10)]
public static void InstantiatesProperly(int size)
{
Inventory inv = new Inventory(size);
Assert.AreEqual(size, inv.Hotbar.Length, "Hotbar has incorrect size");
Assert.AreEqual(size * size, inv.Items.Length, "Items has incorrect size");
Assert.AreEqual(size * 2, inv.Accessories.Length, "Accessories has incorrect size");
Assert.AreEqual(size, inv.Gear.Length, "Gear has incorrect size");
}
[Test]
[TestCase("one", 3)]
[TestCase(null, 1)]
[TestCase("", 4)]
public static void GetsProperHotbarItemTile(string stock_id, int index)
{
Inventory inv = new Inventory(5);
inv.AddToHotbar(new Material(stock_id), index);
Assert.AreEqual(stock_id, inv.GetItemTile(Inventory.InventoryPlace.Hotbar, index).stock_id);
}
[Test]
[TestCase("one", 3)]
[TestCase(null, 1)]
[TestCase("", 4)]
public static void GetsProperItemsItemTile(string stock_id, int index)
{
Inventory inv = new Inventory(5);
inv.AddToItems(new Material(stock_id), index);
Assert.AreEqual(stock_id, inv.GetItemTile(Inventory.InventoryPlace.Items, index).stock_id);
}
[Test]
[TestCase("one", 3)]
[TestCase(null, 1)]
[TestCase("", 4)]
public static void GetsProperAccessoriesItemTile(string stock_id, int index)
{
Inventory inv = new Inventory(5);
inv.AddToAccessories(new Gear(stock_id), index);
Assert.AreEqual(stock_id, inv.GetItemTile(Inventory.InventoryPlace.Accessories, index).stock_id);
}
[Test]
[TestCase("one", 3)]
[TestCase(null, 1)]
[TestCase("", 4)]
public static void GetsProperGearItemTile(string stock_id, int index)
{
Inventory inv = new Inventory(5);
inv.AddToGear(new Gear(stock_id), index);
Assert.AreEqual(stock_id, inv.GetItemTile(Inventory.InventoryPlace.Gear, index).stock_id);
}
}
}
|