|
@@ -1,12 +1,257 @@
|
1
|
1
|
package com.zipcodewilmington.gildedrose;
|
2
|
2
|
|
3
|
3
|
import org.junit.Assert;
|
|
4
|
+import org.junit.Before;
|
4
|
5
|
import org.junit.Test;
|
5
|
6
|
|
6
|
7
|
public class InventoryTest {
|
|
8
|
+
|
7
|
9
|
@Test
|
8
|
|
- public void updateQuantityTest(){
|
9
|
|
- Assert.assertEquals(1, 1);
|
|
10
|
+ public void setNameTest(){
|
|
11
|
+ //Given
|
|
12
|
+ Item candle = new Item("Scented Candle", 30, 40);
|
|
13
|
+ String expected = "Candle";
|
|
14
|
+
|
|
15
|
+ //When
|
|
16
|
+ candle.setName("Candle");
|
|
17
|
+
|
|
18
|
+ //Then
|
|
19
|
+ String actual = candle.getName();
|
|
20
|
+ Assert.assertEquals(expected, actual);
|
10
|
21
|
}
|
|
22
|
+
|
|
23
|
+ @Test
|
|
24
|
+ public void setQualityTest(){
|
|
25
|
+ //Given
|
|
26
|
+ Item candle = new Item("Scented Candle", 30, 40);
|
|
27
|
+ int expected = 25;
|
|
28
|
+
|
|
29
|
+ //When
|
|
30
|
+ candle.setQuality(25);
|
|
31
|
+
|
|
32
|
+ //Then
|
|
33
|
+ int actual = candle.getQuality();
|
|
34
|
+ Assert.assertEquals(expected, actual);
|
|
35
|
+ }
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+ @Test
|
|
39
|
+ public void getNameTest(){
|
|
40
|
+ //Given
|
|
41
|
+ String expected = "Scented Candle";
|
|
42
|
+
|
|
43
|
+ //When
|
|
44
|
+ Item candle = new Item("Scented Candle", 30, 40);
|
|
45
|
+
|
|
46
|
+ //Then
|
|
47
|
+ String actual = candle.getName();
|
|
48
|
+ Assert.assertEquals(expected, actual);
|
|
49
|
+ }
|
|
50
|
+
|
|
51
|
+ @Test
|
|
52
|
+ public void getSellInTest(){
|
|
53
|
+ //Given
|
|
54
|
+ int expected = 30;
|
|
55
|
+
|
|
56
|
+ //When
|
|
57
|
+ Item candle = new Item("Scented Candle", 30, 40);
|
|
58
|
+
|
|
59
|
+ //Then
|
|
60
|
+ int actual = candle.getSellIn();
|
|
61
|
+ Assert.assertEquals(expected, actual);
|
|
62
|
+ }
|
|
63
|
+
|
|
64
|
+ @Test
|
|
65
|
+ public void getQualityTest(){
|
|
66
|
+ //Given
|
|
67
|
+ int expected = 40;
|
|
68
|
+
|
|
69
|
+ //When
|
|
70
|
+ Item candle = new Item("Scented Candle", 30, 40);
|
|
71
|
+
|
|
72
|
+ //Then
|
|
73
|
+ int actual = candle.getQuality();
|
|
74
|
+ Assert.assertEquals(expected, actual);
|
|
75
|
+ }
|
|
76
|
+
|
|
77
|
+ @Test
|
|
78
|
+ public void sulfurasUpdateSellInTest(){
|
|
79
|
+ //Given
|
|
80
|
+ Item sulfuras = new Item("Sulfuras", 0, 80);
|
|
81
|
+ Item[] itemArr = new Item[1];
|
|
82
|
+ itemArr[0] = sulfuras;
|
|
83
|
+ Inventory newInv = new Inventory(itemArr);
|
|
84
|
+ int expected = 0;
|
|
85
|
+
|
|
86
|
+ //When
|
|
87
|
+ newInv.updateSellIn();
|
|
88
|
+
|
|
89
|
+ //Then
|
|
90
|
+ int actual = sulfuras.getSellIn();
|
|
91
|
+
|
|
92
|
+ Assert.assertEquals(expected, actual);
|
|
93
|
+ }
|
|
94
|
+
|
|
95
|
+ @Test
|
|
96
|
+ public void itemAtZeroUpdateSellInTest(){
|
|
97
|
+ //Given
|
|
98
|
+ Item wine = new Item("Wine", 0, 40);
|
|
99
|
+ Item[] itemArr = new Item[1];
|
|
100
|
+ itemArr[0] = wine;
|
|
101
|
+ Inventory newInv = new Inventory(itemArr);
|
|
102
|
+ int expected = 0;
|
|
103
|
+
|
|
104
|
+ //When
|
|
105
|
+ newInv.updateSellIn();
|
|
106
|
+
|
|
107
|
+ //Then
|
|
108
|
+ int actual = wine.getSellIn();
|
|
109
|
+
|
|
110
|
+ Assert.assertEquals(expected, actual);
|
|
111
|
+ }
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+ @Test
|
|
116
|
+ public void allOthersUpdateSellInTest(){
|
|
117
|
+ //Given
|
|
118
|
+ Item candle = new Item("Scented Candle", 30, 40);
|
|
119
|
+ Item[] itemArr = new Item[1];
|
|
120
|
+ itemArr[0] = candle;
|
|
121
|
+ Inventory newInv = new Inventory(itemArr);
|
|
122
|
+ int expected = 29;
|
|
123
|
+
|
|
124
|
+ //When
|
|
125
|
+ newInv.updateSellIn();
|
|
126
|
+
|
|
127
|
+ //
|
|
128
|
+ int actual = candle.getSellIn();
|
|
129
|
+
|
|
130
|
+ Assert.assertEquals(expected, actual);
|
|
131
|
+ }
|
|
132
|
+
|
|
133
|
+ @Test
|
|
134
|
+ public void sulfurasUpdateQualityTest(){
|
|
135
|
+ //Given
|
|
136
|
+ Item sulfuras = new Item("Sulfuras", 0, 80);
|
|
137
|
+ Item[] itemArr = new Item[1];
|
|
138
|
+ itemArr[0] = sulfuras;
|
|
139
|
+ Inventory newInv = new Inventory(itemArr);
|
|
140
|
+ int expected = 80;
|
|
141
|
+
|
|
142
|
+ //When
|
|
143
|
+ newInv.updateSellIn();
|
|
144
|
+ newInv.updateQuality();
|
|
145
|
+
|
|
146
|
+ //Then
|
|
147
|
+ int actual = sulfuras.getQuality();
|
|
148
|
+
|
|
149
|
+ Assert.assertEquals(expected, actual);
|
|
150
|
+ }
|
|
151
|
+
|
|
152
|
+ @Test
|
|
153
|
+ public void backstagePasses9DaysUpdateQualityTest(){
|
|
154
|
+ //Given
|
|
155
|
+ Item backstagePass = new Item("Backstage Passes", 9, 10);
|
|
156
|
+ Item[] itemArr = new Item[1];
|
|
157
|
+ itemArr[0] = backstagePass;
|
|
158
|
+ Inventory newInv = new Inventory(itemArr);
|
|
159
|
+ int expected = 12;
|
|
160
|
+
|
|
161
|
+ //When
|
|
162
|
+ newInv.updateSellIn();
|
|
163
|
+ newInv.updateQuality();
|
|
164
|
+
|
|
165
|
+ //Then
|
|
166
|
+ int actual = backstagePass.getQuality();
|
|
167
|
+
|
|
168
|
+ Assert.assertEquals(expected, actual);
|
|
169
|
+ }
|
|
170
|
+
|
|
171
|
+ @Test
|
|
172
|
+ public void backstagePasses3DaysUpdateQualityTest(){
|
|
173
|
+ //Given
|
|
174
|
+ Item backstagePass = new Item("Backstage Passes", 3, 10);
|
|
175
|
+ Item[] itemArr = new Item[1];
|
|
176
|
+ itemArr[0] = backstagePass;
|
|
177
|
+ Inventory newInv = new Inventory(itemArr);
|
|
178
|
+ int expected = 13;
|
|
179
|
+
|
|
180
|
+ //When
|
|
181
|
+ newInv.updateSellIn();
|
|
182
|
+ newInv.updateQuality();
|
|
183
|
+
|
|
184
|
+ //Then
|
|
185
|
+ int actual = backstagePass.getQuality();
|
|
186
|
+
|
|
187
|
+ Assert.assertEquals(expected, actual);
|
|
188
|
+ }
|
|
189
|
+
|
|
190
|
+ @Test
|
|
191
|
+ public void agedBrieUpdateQualityTest(){
|
|
192
|
+ //Given
|
|
193
|
+ Item agedBrie = new Item("Aged Brie", 20, 5);
|
|
194
|
+ Item[] itemArr = new Item[1];
|
|
195
|
+ itemArr[0] = agedBrie;
|
|
196
|
+ Inventory newInv = new Inventory(itemArr);
|
|
197
|
+ int expected = 6;
|
|
198
|
+
|
|
199
|
+ //When
|
|
200
|
+ newInv.updateSellIn();
|
|
201
|
+ newInv.updateQuality();
|
|
202
|
+
|
|
203
|
+ //Then
|
|
204
|
+ int actual = agedBrie.getQuality();
|
|
205
|
+
|
|
206
|
+ Assert.assertEquals(expected, actual);
|
|
207
|
+ }
|
|
208
|
+
|
|
209
|
+ @Test
|
|
210
|
+ public void sellinIs0UpdateQualityTest(){
|
|
211
|
+ //Given
|
|
212
|
+ Item candle = new Item("Scented Candle", 0, 40);
|
|
213
|
+ Item[] itemArr = new Item[1];
|
|
214
|
+ itemArr[0] = candle;
|
|
215
|
+ Inventory newInv = new Inventory(itemArr);
|
|
216
|
+ int expected = 38;
|
|
217
|
+
|
|
218
|
+ //When
|
|
219
|
+ newInv.updateSellIn();
|
|
220
|
+ newInv.updateQuality();
|
|
221
|
+
|
|
222
|
+ //Then
|
|
223
|
+ int actual = candle.getQuality();
|
|
224
|
+
|
|
225
|
+ Assert.assertEquals(expected, actual);
|
|
226
|
+ }
|
|
227
|
+
|
|
228
|
+ @Test
|
|
229
|
+ public void defaultUpdateQualityTest(){
|
|
230
|
+ //Given
|
|
231
|
+ Item candle = new Item("Scented Candle", 30, 40);
|
|
232
|
+ Item[] itemArr = new Item[1];
|
|
233
|
+ itemArr[0] = candle;
|
|
234
|
+ Inventory newInv = new Inventory(itemArr);
|
|
235
|
+ int expected = 39;
|
|
236
|
+
|
|
237
|
+ //When
|
|
238
|
+ newInv.updateSellIn();
|
|
239
|
+ newInv.updateQuality();
|
|
240
|
+
|
|
241
|
+ //Then
|
|
242
|
+ int actual = candle.getQuality();
|
|
243
|
+
|
|
244
|
+ Assert.assertEquals(expected, actual);
|
|
245
|
+ }
|
|
246
|
+
|
11
|
247
|
}
|
12
|
248
|
|
|
249
|
+/*
|
|
250
|
+Item agedBrie = new Item("Aged Brie", 20, 5);
|
|
251
|
+ itemArr[1] = agedBrie;
|
|
252
|
+ Item backstagePass = new Item("Backstage Passes", 15, 10);
|
|
253
|
+ itemArr[2] = backstagePass;
|
|
254
|
+ Item candle = new Item("Scented Candle", 30, 40);
|
|
255
|
+ itemArr[3] = candle;
|
|
256
|
+ Item avocado = new Item("Avocado", 0, 0);
|
|
257
|
+ itemArr[4] = avocado;*/
|