|
@@ -4,9 +4,111 @@ import org.junit.Assert;
|
4
|
4
|
import org.junit.Test;
|
5
|
5
|
|
6
|
6
|
public class InventoryTest {
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+ @Test
|
|
10
|
+ public void updateQualityPt1() {
|
|
11
|
+
|
|
12
|
+ //Given
|
|
13
|
+ Item item1 = new Item("food", 2, 1);
|
|
14
|
+ Item item2 = new Item("food", 2, 1);
|
|
15
|
+ Item[] items = new Item[]{item1, item2};
|
|
16
|
+ //System.out.println(items);
|
|
17
|
+ Inventory unventory = new Inventory(items);
|
|
18
|
+ // when
|
|
19
|
+ unventory.updateQuality();
|
|
20
|
+ //Then
|
|
21
|
+ int actual = item1.getQuality();
|
|
22
|
+ int expected = 0;
|
|
23
|
+ Assert.assertEquals(expected, actual);
|
|
24
|
+ }
|
|
25
|
+
|
|
26
|
+ @Test
|
|
27
|
+ public void updateQualityPt2() {
|
|
28
|
+ //Given
|
|
29
|
+ Item item1 = new Item("Backstage passes to a TAFKAL80ETC concert", 10, 46);
|
|
30
|
+ Item item2 = new Item("Backstage passes to a TAFKAL80ETC concert", 8, 39);
|
|
31
|
+ Item item3 = new Item("Backstage passes to a TAFKAL80ETC concert", 5, 30);
|
|
32
|
+ Item[] items = new Item[]{item1, item2, item3};
|
|
33
|
+ Inventory newStuff = new Inventory(items);
|
|
34
|
+ //When
|
|
35
|
+ newStuff.updateQuality();
|
|
36
|
+
|
|
37
|
+ //Then
|
|
38
|
+ int actual = item1.getQuality();
|
|
39
|
+ int expected = 48;
|
|
40
|
+ Assert.assertEquals(expected, actual);
|
|
41
|
+ }
|
|
42
|
+
|
7
|
43
|
@Test
|
8
|
|
- public void updateQuantityTest(){
|
9
|
|
- Assert.assertEquals(1, 1);
|
|
44
|
+ public void updateQualityPt3() {
|
|
45
|
+ //Given
|
|
46
|
+ Item item1 = new Item("This is new name", -2,5);
|
|
47
|
+ Item item2 = new Item("Another name mayne", -6,10);
|
|
48
|
+ Item[] items = new Item[]{item1, item2};
|
|
49
|
+ Inventory otherStuff = new Inventory(items);
|
|
50
|
+
|
|
51
|
+ //When
|
|
52
|
+
|
|
53
|
+ otherStuff.updateQuality();
|
|
54
|
+
|
|
55
|
+ //Then
|
|
56
|
+ int actual = item1.getQuality();
|
|
57
|
+ int expected = 3;
|
|
58
|
+ Assert.assertEquals(expected, actual);
|
10
|
59
|
}
|
|
60
|
+
|
|
61
|
+ @Test
|
|
62
|
+ public void updateQualityPt4() {
|
|
63
|
+ //Given
|
|
64
|
+ Item item1 = new Item("Aged Brie", -1, 41);
|
|
65
|
+ Item[] items = new Item[]{item1};
|
|
66
|
+ Inventory differentStuff = new Inventory(items);
|
|
67
|
+
|
|
68
|
+ //When
|
|
69
|
+
|
|
70
|
+ differentStuff.updateQuality();
|
|
71
|
+
|
|
72
|
+ //Then
|
|
73
|
+
|
|
74
|
+ int actual = item1.getQuality();
|
|
75
|
+ int expected = 43;
|
|
76
|
+ Assert.assertEquals(expected, actual);
|
|
77
|
+ }
|
|
78
|
+ @Test
|
|
79
|
+ public void updateQualityPt5() {
|
|
80
|
+ //Given
|
|
81
|
+ Item item1 = new Item ("Backstage passes to a TAFKAL80ETC concert", -2, 2);
|
|
82
|
+ Item[] items = new Item[]{item1};
|
|
83
|
+ Inventory finalVariable = new Inventory(items);
|
|
84
|
+
|
|
85
|
+ //When
|
|
86
|
+ finalVariable.updateQuality();
|
|
87
|
+ //Then
|
|
88
|
+ int actual = item1.getQuality();
|
|
89
|
+ int expected = 0;
|
|
90
|
+ Assert.assertEquals(expected, actual);
|
|
91
|
+
|
|
92
|
+ }
|
|
93
|
+
|
|
94
|
+ @Test
|
|
95
|
+ public void updateQualityPt6() {
|
|
96
|
+ //Given
|
|
97
|
+ Item item1 = new Item("Backstage passes to a TAFKAL80ETC concert", -2, 2);
|
|
98
|
+ Item[] items = new Item[]{item1};
|
|
99
|
+ Inventory variable = new Inventory(items);
|
|
100
|
+
|
|
101
|
+ //When
|
|
102
|
+ item1.setName("Final Name");
|
|
103
|
+
|
|
104
|
+ //Then
|
|
105
|
+ String expected = "Final Name";
|
|
106
|
+ String actual = item1.getName();
|
|
107
|
+ Assert.assertEquals(expected, actual);
|
|
108
|
+
|
|
109
|
+ }
|
|
110
|
+
|
|
111
|
+
|
11
|
112
|
}
|
12
|
113
|
|
|
114
|
+
|