|
@@ -5,8 +5,184 @@ 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 checkSetName(){
|
|
9
|
+
|
|
10
|
+ Item normalItem = new Item("Sock", 20, 9);
|
|
11
|
+ Item[] itemList = new Item[1];
|
|
12
|
+ itemList[0] = normalItem;
|
|
13
|
+ itemList[0].setName("Sulfuras");
|
|
14
|
+ String actual = itemList[0].getName();
|
|
15
|
+
|
|
16
|
+ Assert.assertEquals("Sulfuras",actual);
|
|
17
|
+ }
|
|
18
|
+
|
|
19
|
+ @Test
|
|
20
|
+ public void checkSetSellin(){
|
|
21
|
+
|
|
22
|
+ Item normalItem = new Item("Sock", 20, 9);
|
|
23
|
+ Item[] itemList = new Item[1];
|
|
24
|
+ itemList[0] = normalItem;
|
|
25
|
+ itemList[0].setSellIn(10);
|
|
26
|
+ int actual = itemList[0].getSellIn();
|
|
27
|
+
|
|
28
|
+ Assert.assertEquals(10,actual);
|
|
29
|
+ }
|
|
30
|
+
|
|
31
|
+ @Test
|
|
32
|
+ public void checkNormalQuality(){
|
|
33
|
+ //Given
|
|
34
|
+ Item normalItem = new Item("Sock", 20, 9);
|
|
35
|
+ Item[] itemList = new Item[1];
|
|
36
|
+ itemList[0] = normalItem;
|
|
37
|
+
|
|
38
|
+ Inventory testInventory = new Inventory(itemList);
|
|
39
|
+ testInventory.updateQuality();
|
|
40
|
+
|
|
41
|
+ int actual = itemList[0].getQuality();
|
|
42
|
+
|
|
43
|
+ Assert.assertEquals(8, actual);
|
|
44
|
+ }
|
|
45
|
+ @Test
|
|
46
|
+ public void checkPastSellin(){
|
|
47
|
+ //Given
|
|
48
|
+ Item normalItem = new Item("Sock", -1, 9);
|
|
49
|
+ Item[] itemList = new Item[1];
|
|
50
|
+ itemList[0] = normalItem;
|
|
51
|
+
|
|
52
|
+ Inventory testInventory = new Inventory(itemList);
|
|
53
|
+ testInventory.updateQuality();
|
|
54
|
+
|
|
55
|
+ int actual = itemList[0].getQuality();
|
|
56
|
+
|
|
57
|
+ Assert.assertEquals(7, actual);
|
|
58
|
+ }
|
|
59
|
+ @Test
|
|
60
|
+ public void checkSulfuras(){
|
|
61
|
+ //Given
|
|
62
|
+ Item normalItem = new Item("Sulfuras", -1, 9);
|
|
63
|
+ Item[] itemList = new Item[1];
|
|
64
|
+ itemList[0] = normalItem;
|
|
65
|
+
|
|
66
|
+ Inventory testInventory = new Inventory(itemList);
|
|
67
|
+ testInventory.updateQuality();
|
|
68
|
+
|
|
69
|
+ int actual = itemList[0].getQuality();
|
|
70
|
+
|
|
71
|
+ Assert.assertEquals(80, actual);
|
|
72
|
+ }
|
|
73
|
+ @Test
|
|
74
|
+ public void checkeAgedBrie(){
|
|
75
|
+ //Given
|
|
76
|
+ Item normalItem = new Item("Aged Brie", -1, 9);
|
|
77
|
+ Item[] itemList = new Item[1];
|
|
78
|
+ itemList[0] = normalItem;
|
|
79
|
+
|
|
80
|
+ Inventory testInventory = new Inventory(itemList);
|
|
81
|
+ testInventory.updateQuality();
|
|
82
|
+
|
|
83
|
+ int actual = itemList[0].getQuality();
|
|
84
|
+
|
|
85
|
+ Assert.assertEquals(10, actual);
|
|
86
|
+ }
|
|
87
|
+ @Test
|
|
88
|
+ public void checkBackStagePassesDay20(){
|
|
89
|
+ //Given
|
|
90
|
+ Item normalItem = new Item("Backstage Pass", 20, 9);
|
|
91
|
+ Item[] itemList = new Item[1];
|
|
92
|
+ itemList[0] = normalItem;
|
|
93
|
+
|
|
94
|
+ Inventory testInventory = new Inventory(itemList);
|
|
95
|
+ testInventory.updateQuality();
|
|
96
|
+
|
|
97
|
+ int actual = itemList[0].getQuality();
|
|
98
|
+
|
|
99
|
+ Assert.assertEquals(10, actual);
|
10
|
100
|
}
|
|
101
|
+ @Test
|
|
102
|
+ public void checkBackStagePassesDay10(){
|
|
103
|
+ //Given
|
|
104
|
+ Item normalItem = new Item("Backstage Pass", 10, 9);
|
|
105
|
+ Item[] itemList = new Item[1];
|
|
106
|
+ itemList[0] = normalItem;
|
|
107
|
+
|
|
108
|
+ Inventory testInventory = new Inventory(itemList);
|
|
109
|
+ testInventory.updateQuality();
|
|
110
|
+
|
|
111
|
+ int actual = itemList[0].getQuality();
|
|
112
|
+
|
|
113
|
+ Assert.assertEquals(11, actual);
|
|
114
|
+ }
|
|
115
|
+ @Test
|
|
116
|
+ public void checkBackStagePassesDay5(){
|
|
117
|
+ //Given
|
|
118
|
+ Item normalItem = new Item("Backstage Pass", 5, 9);
|
|
119
|
+ Item[] itemList = new Item[1];
|
|
120
|
+ itemList[0] = normalItem;
|
|
121
|
+
|
|
122
|
+ Inventory testInventory = new Inventory(itemList);
|
|
123
|
+ testInventory.updateQuality();
|
|
124
|
+
|
|
125
|
+ int actual = itemList[0].getQuality();
|
|
126
|
+
|
|
127
|
+ Assert.assertEquals(12, actual);
|
|
128
|
+ }
|
|
129
|
+ @Test
|
|
130
|
+ public void checkBackStagePassesDay0(){
|
|
131
|
+ //Given
|
|
132
|
+ Item normalItem = new Item("Backstage Pass", 0, 9);
|
|
133
|
+ Item[] itemList = new Item[1];
|
|
134
|
+ itemList[0] = normalItem;
|
|
135
|
+
|
|
136
|
+ Inventory testInventory = new Inventory(itemList);
|
|
137
|
+ testInventory.updateQuality();
|
|
138
|
+
|
|
139
|
+ int actual = itemList[0].getQuality();
|
|
140
|
+
|
|
141
|
+ Assert.assertEquals(0, actual);
|
|
142
|
+ }
|
|
143
|
+ @Test
|
|
144
|
+ public void checkConjured(){
|
|
145
|
+ //Given
|
|
146
|
+ Item normalItem = new Item("Conjured Item", 4, 9);
|
|
147
|
+ Item[] itemList = new Item[1];
|
|
148
|
+ itemList[0] = normalItem;
|
|
149
|
+
|
|
150
|
+ Inventory testInventory = new Inventory(itemList);
|
|
151
|
+ testInventory.updateQuality();
|
|
152
|
+
|
|
153
|
+ int actual = itemList[0].getQuality();
|
|
154
|
+
|
|
155
|
+ Assert.assertEquals(7, actual);
|
|
156
|
+ }
|
|
157
|
+
|
|
158
|
+ @Test
|
|
159
|
+ public void checkMin(){
|
|
160
|
+ //Given
|
|
161
|
+ Item normalItem = new Item("Conjured Item", 4, 0);
|
|
162
|
+ Item[] itemList = new Item[1];
|
|
163
|
+ itemList[0] = normalItem;
|
|
164
|
+
|
|
165
|
+ Inventory testInventory = new Inventory(itemList);
|
|
166
|
+ testInventory.updateQuality();
|
|
167
|
+
|
|
168
|
+ int actual = itemList[0].getQuality();
|
|
169
|
+
|
|
170
|
+ Assert.assertEquals(0, actual);
|
|
171
|
+ }
|
|
172
|
+ @Test
|
|
173
|
+ public void checkMax(){
|
|
174
|
+ //Given
|
|
175
|
+ Item normalItem = new Item("Backstage Pass", 4, 50);
|
|
176
|
+ Item[] itemList = new Item[1];
|
|
177
|
+ itemList[0] = normalItem;
|
|
178
|
+
|
|
179
|
+ Inventory testInventory = new Inventory(itemList);
|
|
180
|
+ testInventory.updateQuality();
|
|
181
|
+
|
|
182
|
+ int actual = itemList[0].getQuality();
|
|
183
|
+
|
|
184
|
+ Assert.assertEquals(50, actual);
|
|
185
|
+ }
|
|
186
|
+
|
11
|
187
|
}
|
12
|
188
|
|