|
@@ -5,8 +5,70 @@ 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 updateQuantity_forAgeBrie(){
|
|
9
|
+ int sellIn = 5;
|
|
10
|
+ int quality = 2;
|
|
11
|
+ Item agedBrie = new Item("Aged Brie", sellIn, quality);
|
|
12
|
+
|
|
13
|
+ Item[] items = {agedBrie};
|
|
14
|
+ Inventory inventory = new Inventory(items);
|
|
15
|
+
|
|
16
|
+ //invoke method under test
|
|
17
|
+ inventory.updateQuality();
|
|
18
|
+
|
|
19
|
+ //verify result
|
|
20
|
+ int expectedQuality = quality + 1;
|
|
21
|
+ Assert.assertEquals(expectedQuality, agedBrie.getQuality());
|
|
22
|
+ }
|
|
23
|
+
|
|
24
|
+ @Test
|
|
25
|
+ public void updateQuantity_forAgeBrieWhenQualityIs50(){
|
|
26
|
+ int sellIn = 5;
|
|
27
|
+ int quality = 50;
|
|
28
|
+ Item agedBrie = new Item("Aged Brie", sellIn, quality);
|
|
29
|
+
|
|
30
|
+ Item[] items = {agedBrie};
|
|
31
|
+ Inventory inventory = new Inventory(items);
|
|
32
|
+
|
|
33
|
+ //invoke method under test
|
|
34
|
+ inventory.updateQuality();
|
|
35
|
+
|
|
36
|
+ //verify result
|
|
37
|
+ int expectedQuality = quality;
|
|
38
|
+ Assert.assertEquals(expectedQuality, agedBrie.getQuality());
|
|
39
|
+ }
|
|
40
|
+ @Test
|
|
41
|
+ public void updateQuantity_forAgeBrieWhenQualityIs49(){
|
|
42
|
+ int sellIn = 5;
|
|
43
|
+ int quality = 30;
|
|
44
|
+ Item agedBrie = new Item("Aged Brie", sellIn, quality);
|
|
45
|
+
|
|
46
|
+ Item[] items = {agedBrie};
|
|
47
|
+ Inventory inventory = new Inventory(items);
|
|
48
|
+
|
|
49
|
+ //invoke method under test
|
|
50
|
+ inventory.updateQuality();
|
|
51
|
+
|
|
52
|
+ //verify result
|
|
53
|
+ int expectedQuality = quality+1;
|
|
54
|
+ Assert.assertEquals(expectedQuality, agedBrie.getQuality());
|
10
|
55
|
}
|
|
56
|
+ @Test
|
|
57
|
+ public void updateQuantity_forBackstagepasses(){
|
|
58
|
+ int sellIn = 5;
|
|
59
|
+ int quality = 10;
|
|
60
|
+ Item agedBrie = new Item("Backstage passes", sellIn, quality);
|
|
61
|
+
|
|
62
|
+ Item[] items = {agedBrie};
|
|
63
|
+ Inventory inventory = new Inventory(items);
|
|
64
|
+
|
|
65
|
+ //invoke method under test
|
|
66
|
+ inventory.updateQuality();
|
|
67
|
+
|
|
68
|
+ //verify result
|
|
69
|
+ int expectedQuality = quality;
|
|
70
|
+ Assert.assertEquals(expectedQuality, agedBrie.getQuality());
|
|
71
|
+
|
|
72
|
+}
|
11
|
73
|
}
|
12
|
74
|
|