|
@@ -5,8 +5,234 @@ import org.junit.Test;
|
5
|
5
|
|
6
|
6
|
public class InventoryTest {
|
7
|
7
|
@Test
|
8
|
|
- public void updateQuantityTest(){
|
9
|
|
- Assert.assertEquals(1, 1);
|
|
8
|
+ public void testBrieQuality() {
|
|
9
|
+ Item brie = new Item("Aged Brie", 10, 45);
|
|
10
|
+ Item[] item = {brie};
|
|
11
|
+ Inventory inventory = new Inventory(item);
|
|
12
|
+
|
|
13
|
+ inventory.updateQuality(brie);
|
|
14
|
+
|
|
15
|
+ int expected = 46;
|
|
16
|
+ int actual = brie.getQuality();
|
|
17
|
+
|
|
18
|
+ Assert.assertEquals(expected, actual);
|
|
19
|
+ }
|
|
20
|
+
|
|
21
|
+ @Test
|
|
22
|
+ public void testBrieQuality_PastSellIn() {
|
|
23
|
+ Item brie = new Item("Aged Brie", -2, 45);
|
|
24
|
+ Item[] item = {brie};
|
|
25
|
+ Inventory inventory = new Inventory(item);
|
|
26
|
+
|
|
27
|
+ inventory.updateQuality(brie);
|
|
28
|
+
|
|
29
|
+ int expected = 47;
|
|
30
|
+ int actual = brie.getQuality();
|
|
31
|
+
|
|
32
|
+ Assert.assertEquals(expected, actual);
|
|
33
|
+ }
|
|
34
|
+
|
|
35
|
+ @Test
|
|
36
|
+ public void testBackstageQuality() {
|
|
37
|
+ Item backstage = new Item("Backstage passes to a TAFKAL80ETC concert", 15, 45);
|
|
38
|
+ Item[] item = {backstage};
|
|
39
|
+ Inventory inventory = new Inventory(item);
|
|
40
|
+
|
|
41
|
+ inventory.updateQuality(backstage);
|
|
42
|
+
|
|
43
|
+ int expected = 44;
|
|
44
|
+ int actual = backstage.getQuality();
|
|
45
|
+
|
|
46
|
+ Assert.assertEquals(expected, actual);
|
|
47
|
+ }
|
|
48
|
+
|
|
49
|
+ @Test
|
|
50
|
+ public void testBackstageQuality_LessThanTenDays() {
|
|
51
|
+ Item backstage = new Item("Backstage passes to a TAFKAL80ETC concert", 8, 45);
|
|
52
|
+ Item[] item = {backstage};
|
|
53
|
+ Inventory inventory = new Inventory(item);
|
|
54
|
+
|
|
55
|
+ inventory.updateQuality(backstage);
|
|
56
|
+
|
|
57
|
+ int expected = 47;
|
|
58
|
+ int actual = backstage.getQuality();
|
|
59
|
+
|
|
60
|
+ Assert.assertEquals(expected, actual);
|
|
61
|
+ }
|
|
62
|
+
|
|
63
|
+ @Test
|
|
64
|
+ public void testBackstageQuality_LessThanFiveDays() {
|
|
65
|
+ Item backstage = new Item("Backstage passes to a TAFKAL80ETC concert", 4, 45);
|
|
66
|
+ Item[] item = {backstage};
|
|
67
|
+ Inventory inventory = new Inventory(item);
|
|
68
|
+
|
|
69
|
+ inventory.updateQuality(backstage);
|
|
70
|
+
|
|
71
|
+ int expected = 48;
|
|
72
|
+ int actual = backstage.getQuality();
|
|
73
|
+
|
|
74
|
+ Assert.assertEquals(expected, actual);
|
|
75
|
+ }
|
|
76
|
+
|
|
77
|
+ @Test
|
|
78
|
+ public void testBackstageQuality_AfterConcert() {
|
|
79
|
+ Item backstage = new Item("Backstage passes to a TAFKAL80ETC concert", 0, 50);
|
|
80
|
+ Item[] item = {backstage};
|
|
81
|
+ Inventory inventory = new Inventory(item);
|
|
82
|
+
|
|
83
|
+ inventory.updateQuality(backstage);
|
|
84
|
+
|
|
85
|
+ int expected = 0;
|
|
86
|
+ int actual = backstage.getQuality();
|
|
87
|
+
|
|
88
|
+ Assert.assertEquals(expected, actual);
|
|
89
|
+ }
|
|
90
|
+
|
|
91
|
+ @Test
|
|
92
|
+ public void testSulfurasQuality() {
|
|
93
|
+ Item sulfuras = new Item("Sulfuras, Hand of Ragnaros", 10, 80);
|
|
94
|
+ Item[] item = {sulfuras};
|
|
95
|
+ Inventory inventory = new Inventory(item);
|
|
96
|
+
|
|
97
|
+ inventory.updateQuality(sulfuras);
|
|
98
|
+
|
|
99
|
+ int expected = 80;
|
|
100
|
+ int actual = sulfuras.getQuality();
|
|
101
|
+
|
|
102
|
+ Assert.assertEquals(expected, actual);
|
10
|
103
|
}
|
|
104
|
+
|
|
105
|
+ @Test
|
|
106
|
+ public void testNormalItemQuality() {
|
|
107
|
+ Item normal = new Item("Generic Mana Potion", 10, 45);
|
|
108
|
+ Item[] item = {normal};
|
|
109
|
+ Inventory inventory = new Inventory(item);
|
|
110
|
+
|
|
111
|
+ inventory.updateQuality(normal);
|
|
112
|
+
|
|
113
|
+ int expected = 44;
|
|
114
|
+ int actual = normal.getQuality();
|
|
115
|
+
|
|
116
|
+ Assert.assertEquals(expected, actual);
|
|
117
|
+ }
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+ @Test
|
|
121
|
+ public void testNormalItemQuality_PastSellIn() {
|
|
122
|
+ Item normal = new Item("Generic Mana Potion", -1, 10);
|
|
123
|
+ Item[] item = {normal};
|
|
124
|
+ Inventory inventory = new Inventory(item);
|
|
125
|
+
|
|
126
|
+ inventory.updateQuality(normal);
|
|
127
|
+
|
|
128
|
+ int expected = 8;
|
|
129
|
+ int actual = normal.getQuality();
|
|
130
|
+
|
|
131
|
+ Assert.assertEquals(expected, actual);
|
|
132
|
+ }
|
|
133
|
+
|
|
134
|
+ @Test
|
|
135
|
+ public void testConjuredItemQuality () {
|
|
136
|
+ Item conjured = new Item("Sulfuros, Hand of Rognoros (not to be confused with Ragnaros)", 5, 45);
|
|
137
|
+ Item[] item = {conjured};
|
|
138
|
+ Inventory inventory = new Inventory(item);
|
|
139
|
+
|
|
140
|
+ inventory.updateQuality(conjured);
|
|
141
|
+
|
|
142
|
+ int expected = 43;
|
|
143
|
+ int actual = conjured.getQuality();
|
|
144
|
+
|
|
145
|
+ Assert.assertEquals(expected, actual);
|
|
146
|
+ }
|
|
147
|
+
|
|
148
|
+ @Test
|
|
149
|
+ public void testConjuredItemQuality_PastSellIn () {
|
|
150
|
+ Item conjured = new Item("Sulfuros, Hand of Rognoros (not to be confused with Ragnaros)", -1, 10);
|
|
151
|
+ Item[] item = {conjured};
|
|
152
|
+ Inventory inventory = new Inventory(item);
|
|
153
|
+
|
|
154
|
+ inventory.updateQuality(conjured);
|
|
155
|
+
|
|
156
|
+ int expected = 6;
|
|
157
|
+ int actual = conjured.getQuality();
|
|
158
|
+
|
|
159
|
+ Assert.assertEquals(expected, actual);
|
|
160
|
+ }
|
|
161
|
+
|
|
162
|
+ @Test
|
|
163
|
+ public void testNormalItemSellIn () {
|
|
164
|
+ Item normal = new Item("Generic Mana Potion", 5, 45);
|
|
165
|
+ Item[] item = {normal};
|
|
166
|
+ Inventory inventory = new Inventory(item);
|
|
167
|
+
|
|
168
|
+ inventory.updateSellIn(normal);
|
|
169
|
+
|
|
170
|
+ int expected = 4;
|
|
171
|
+ int actual = normal.getSellIn();
|
|
172
|
+
|
|
173
|
+ Assert.assertEquals(expected, actual);
|
|
174
|
+ }
|
|
175
|
+
|
|
176
|
+ @Test
|
|
177
|
+ public void testSulfurasItemSellIn () {
|
|
178
|
+ Item sulfuras = new Item("Sulfuras, Hand of Ragnaros", 15, 45);
|
|
179
|
+ Item[] item = {sulfuras};
|
|
180
|
+ Inventory inventory = new Inventory(item);
|
|
181
|
+
|
|
182
|
+ inventory.updateSellIn(sulfuras);
|
|
183
|
+
|
|
184
|
+ int expected = 15;
|
|
185
|
+ int actual = sulfuras.getSellIn();
|
|
186
|
+
|
|
187
|
+ Assert.assertEquals(expected, actual);
|
|
188
|
+ }
|
|
189
|
+
|
|
190
|
+// @Test
|
|
191
|
+// public void updateBrieQualityTest_PastSellIn() {
|
|
192
|
+// Item brie = new Item("Aged Brie", -2, 45);
|
|
193
|
+// Item[] item = {brie};
|
|
194
|
+// Inventory inventory = new Inventory(item);
|
|
195
|
+//
|
|
196
|
+// inventory.updateQuality();
|
|
197
|
+//
|
|
198
|
+// int expected = 47;
|
|
199
|
+// int actual = brie.getQuality();
|
|
200
|
+//
|
|
201
|
+// Assert.assertEquals(expected, actual);
|
|
202
|
+// }
|
|
203
|
+
|
|
204
|
+// @Test
|
|
205
|
+// public void testIsAgedBrie() {
|
|
206
|
+// Item item = new Item("Aged Brie", 6, 50);
|
|
207
|
+//
|
|
208
|
+// String expected = "Aged Brie";
|
|
209
|
+//
|
|
210
|
+// String actual = item.getName();
|
|
211
|
+//
|
|
212
|
+// Assert.assertEquals(expected, actual);
|
|
213
|
+// }
|
|
214
|
+//
|
|
215
|
+// @Test
|
|
216
|
+// public void testIsBackstagePass() {
|
|
217
|
+// Item item = new Item("Backstage passes to a TAFKAL80ETC concert", 6, 50);
|
|
218
|
+//
|
|
219
|
+// String expected = "Backstage passes to a TAFKAL80ETC concert";
|
|
220
|
+//
|
|
221
|
+// String actual = item.getName();
|
|
222
|
+//
|
|
223
|
+// Assert.assertEquals(expected, actual);
|
|
224
|
+// }
|
|
225
|
+//
|
|
226
|
+// @Test
|
|
227
|
+// public void testIsSulfuras() {
|
|
228
|
+// Item item = new Item("Sulfuras, Hand of Ragnaros", 6, 50);
|
|
229
|
+//
|
|
230
|
+// String expected = "Sulfuras, Hand of Ragnaros";
|
|
231
|
+//
|
|
232
|
+// String actual = item.getName();
|
|
233
|
+//
|
|
234
|
+// Assert.assertEquals(expected, actual);
|
|
235
|
+//
|
|
236
|
+// }
|
11
|
237
|
}
|
12
|
238
|
|