|
@@ -8,14 +8,18 @@ public class InventoryTest {
|
8
|
8
|
private static final String AGED_BRIE_NAME = "Aged Brie";
|
9
|
9
|
private static final String BACKSTAGE_PASS_NAME = "Backstage passes to a TAFKAL80ETC concert";
|
10
|
10
|
private static final String NORMAL_ITEM_NAME = "+5 Dexterity Vest";
|
11
|
|
-
|
|
11
|
+ private static final String CONJURED_ITEM_NAME = "Conjured Holy Water";
|
|
12
|
+ private static final int minimumQuality = 0;
|
|
13
|
+
|
12
|
14
|
private Item sulfuras;
|
13
|
15
|
private Item normalItem;
|
14
|
|
-
|
|
16
|
+ private Item conjuredItem;
|
|
17
|
+
|
15
|
18
|
@Before
|
16
|
19
|
public void setup(){
|
17
|
20
|
sulfuras = new Item("Sulfuras, Hand of Ragnaros", 0, 80);
|
18
|
21
|
normalItem = new Item(NORMAL_ITEM_NAME, 10, 20);
|
|
22
|
+ conjuredItem = new Item(CONJURED_ITEM_NAME, 10, MAX_QUALITY);
|
19
|
23
|
}
|
20
|
24
|
|
21
|
25
|
@Test
|
|
@@ -28,6 +32,7 @@ public class InventoryTest {
|
28
|
32
|
|
29
|
33
|
assertEquals(expectedQuality, sulfuras.getQuality());
|
30
|
34
|
}
|
|
35
|
+
|
31
|
36
|
@Test
|
32
|
37
|
public void testUpdate_ForSulfurasSellIn() throws Exception {
|
33
|
38
|
int expectedSellIn = sulfuras.getSellIn();
|
|
@@ -119,4 +124,40 @@ public class InventoryTest {
|
119
|
124
|
|
120
|
125
|
assertEquals(expectedQuality, agedBrie.getQuality());
|
121
|
126
|
}
|
122
|
|
-}
|
|
127
|
+
|
|
128
|
+ @Test
|
|
129
|
+ public void testUpdate_WhenConjuredItem() throws Exception {
|
|
130
|
+ Item conjuredItem = new Item(CONJURED_ITEM_NAME, 10, 25);
|
|
131
|
+ int expectedQuality = conjuredItem.getQuality() - 1;
|
|
132
|
+ Item[] items = {conjuredItem};
|
|
133
|
+ Inventory sut = new Inventory(items);
|
|
134
|
+
|
|
135
|
+ sut.updateQuality();
|
|
136
|
+
|
|
137
|
+ assertEquals(expectedQuality, conjuredItem.getQuality());
|
|
138
|
+ }
|
|
139
|
+
|
|
140
|
+ @Test
|
|
141
|
+ public void testUpdate_WhenConjuredItemIsMaxQuality() throws Exception {
|
|
142
|
+ Item agedBrie = new Item(CONJURED_ITEM_NAME, 10, MAX_QUALITY);
|
|
143
|
+ int expectedQuality = conjuredItem.getQuality();
|
|
144
|
+ Item[] items = {conjuredItem};
|
|
145
|
+ Inventory sut = new Inventory(items);
|
|
146
|
+
|
|
147
|
+ sut.updateQuality();
|
|
148
|
+
|
|
149
|
+ assertEquals(expectedQuality, conjuredItem.getQuality());
|
|
150
|
+ }
|
|
151
|
+
|
|
152
|
+ @Test
|
|
153
|
+ public void testUpdate_WhenConjuredItemOnceTheSellInDatePassed() throws Exception {
|
|
154
|
+ Item conjuredItem = new Item(CONJURED_ITEM_NAME, -1, 10);
|
|
155
|
+ int expectedQuality = conjuredItem.getQuality() - 2;
|
|
156
|
+ Item[] items = {conjuredItem};
|
|
157
|
+ Inventory sut = new Inventory(items);
|
|
158
|
+
|
|
159
|
+ sut.updateQuality();
|
|
160
|
+
|
|
161
|
+ assertEquals(expectedQuality, conjuredItem.getQuality());
|
|
162
|
+ }
|
|
163
|
+}
|