|
@@ -4,9 +4,108 @@ import org.junit.Assert;
|
4
|
4
|
import org.junit.Test;
|
5
|
5
|
|
6
|
6
|
public class InventoryTest {
|
|
7
|
+
|
7
|
8
|
@Test
|
8
|
|
- public void updateQuantityTest(){
|
9
|
|
- Assert.assertEquals(1, 1);
|
|
9
|
+ public void testAdjustItem(){
|
|
10
|
+ Item agedBrie = new Item("Aged Brie", 10, 30);
|
|
11
|
+ Item backstagePasses = new Item("Backstage passes to a TAFKAL80ETC concert", 10, 30);
|
|
12
|
+ Item sulfuras = new Item("Sulfuras, Hand of Ragnaros", 10, 80);
|
|
13
|
+ Item[] expected = {agedBrie, backstagePasses, sulfuras};
|
|
14
|
+
|
|
15
|
+ Item[] actual = expected;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+ Assert.assertEquals(expected, actual);
|
10
|
20
|
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+ @Test
|
|
24
|
+ public void testSulfurasHandler() {
|
|
25
|
+ Item agedBrie = new Item("Aged Brie", 10, 30);
|
|
26
|
+ Item backstagePasses = new Item("Backstage passes to a TAFKAL80ETC concert", 10, 30);
|
|
27
|
+ Item sulfuras = new Item("Sulfuras, Hand of Ragnaros", 10, 80);
|
|
28
|
+ Item[] item = {agedBrie, backstagePasses, sulfuras};
|
|
29
|
+ Inventory inv = new Inventory(item);
|
|
30
|
+ int before = sulfuras.getQuality();
|
|
31
|
+ int expected = before;
|
|
32
|
+
|
|
33
|
+ int actual = before;
|
|
34
|
+
|
|
35
|
+ Assert.assertEquals(expected, actual);
|
|
36
|
+ }
|
|
37
|
+
|
|
38
|
+ @Test
|
|
39
|
+ public void testAgedBrieHandler() {
|
|
40
|
+ // given
|
|
41
|
+ Item agedBrie = new Item("Aged Brie", 10, 30);
|
|
42
|
+ Item backstagePasses = new Item("Backstage passes to a TAFKAL80ETC concert", 10, 30);
|
|
43
|
+ Item sulfuras = new Item("Sulfuras, Hand of Ragnaros", 10, 80);
|
|
44
|
+ Item[] item = {agedBrie, backstagePasses, sulfuras};
|
|
45
|
+ Inventory inv = new Inventory(item);
|
|
46
|
+ int expected = agedBrie.getQuality() + 1;
|
|
47
|
+
|
|
48
|
+ // when
|
|
49
|
+ inv.adjustItemQuality(agedBrie, 1);
|
|
50
|
+ int actual= agedBrie.getQuality();
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+ //then
|
|
54
|
+ Assert.assertEquals(expected, actual);
|
|
55
|
+ }
|
|
56
|
+
|
|
57
|
+ @Test
|
|
58
|
+ public void testBackstagePassesHandler(){
|
|
59
|
+ // given
|
|
60
|
+ Item agedBrie = new Item("Aged Brie", 10, 30);
|
|
61
|
+ Item backstagePasses = new Item("Backstage passes to a TAFKAL80ETC concert", 10, 30);
|
|
62
|
+ Item sulfuras = new Item("Sulfuras, Hand of Ragnaros", 10, 80);
|
|
63
|
+ Item[] item = {agedBrie, backstagePasses, sulfuras};
|
|
64
|
+ Inventory inv = new Inventory(item);
|
|
65
|
+ int expected = backstagePasses.getQuality() + 2;
|
|
66
|
+
|
|
67
|
+ //when
|
|
68
|
+ inv.adjustItemQuality(backstagePasses, 2);
|
|
69
|
+ int actual = backstagePasses.getQuality();
|
|
70
|
+
|
|
71
|
+ //then
|
|
72
|
+ Assert.assertEquals(expected, actual);
|
|
73
|
+ }
|
|
74
|
+
|
|
75
|
+ @Test
|
|
76
|
+ public void testIsMaxQuality(){
|
|
77
|
+ //given
|
|
78
|
+ Item agedBrie = new Item("Aged Brie", 10, 50);
|
|
79
|
+ Item backstagePasses = new Item("Backstage passes to a TAFKAL80ETC concert", 10, 50);
|
|
80
|
+ Item[] item = {agedBrie, backstagePasses};
|
|
81
|
+ Inventory inv = new Inventory(item);
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+ Assert.assertTrue(inv.isMaxQuality(50));
|
|
85
|
+ }
|
|
86
|
+
|
|
87
|
+ @Test
|
|
88
|
+ public void testItemisExpired(){
|
|
89
|
+ Item agedBrie = new Item("Aged Brie", 0, 50);
|
|
90
|
+ Item backstagePasses = new Item("Backstage passes to a TAFKAL80ETC concert", 0, 50);
|
|
91
|
+ Item[] item = {agedBrie, backstagePasses};
|
|
92
|
+ Inventory inv = new Inventory(item);
|
|
93
|
+
|
|
94
|
+ Assert.assertTrue(inv.itemIsExpired(agedBrie));
|
|
95
|
+ }
|
|
96
|
+
|
|
97
|
+ @Test
|
|
98
|
+ public void testAdjustItemSellIn(){
|
|
99
|
+ Item agedBrie = new Item("Aged Brie", 1, 50);
|
|
100
|
+ Item backstagePasses = new Item("Backstage passes to a TAFKAL80ETC concert", 1, 50);
|
|
101
|
+ Item sulfuras = new Item("Sulfuras, Hand of Ragnaros", 1, 80);
|
|
102
|
+ Item[] item = {agedBrie, backstagePasses, sulfuras};
|
|
103
|
+ Inventory inv = new Inventory(item);
|
|
104
|
+
|
|
105
|
+ inv.adjustItemSellIn(agedBrie);
|
|
106
|
+
|
|
107
|
+ Assert.assertTrue(inv.itemIsExpired(agedBrie));
|
|
108
|
+ }
|
|
109
|
+
|
11
|
110
|
}
|
12
|
111
|
|