Explorar el Código

wrote inventory tests for 100% coverage

Michelle DiMarino hace 6 años
padre
commit
da1415849c
Se han modificado 1 ficheros con 153 adiciones y 5 borrados
  1. 153
    5
      src/test/java/com/zipcodewilmington/gildedrose/InventoryTest.java

+ 153
- 5
src/test/java/com/zipcodewilmington/gildedrose/InventoryTest.java Ver fichero

@@ -3,10 +3,158 @@ package com.zipcodewilmington.gildedrose;
3 3
 import org.junit.Assert;
4 4
 import org.junit.Test;
5 5
 
6
-public class InventoryTest {
7
-    @Test
8
-    public void updateQuantityTest(){
9
-        Assert.assertEquals(1, 1);
6
+    public class InventoryTest {
7
+        @Test
8
+        public void updateQuality(){
9
+            Item carrots = new Item("carrots",-1, 10 );
10
+            Item array1[] = new Item[1];
11
+            array1[0] = carrots;
12
+            Inventory inventory = new Inventory(array1);
13
+            int expectedOutput = 8;
14
+
15
+            //when
16
+
17
+            inventory.updateQuality();
18
+            int actualOutput = carrots.getQuality();
19
+
20
+            //then
21
+            Assert.assertEquals(expectedOutput, actualOutput);
22
+
23
+
24
+        }
25
+
26
+        @Test
27
+        public void updateQuality2() {
28
+            Item carrots = new Item("carrots",3, -1 );
29
+            Item array1[] = new Item[1];
30
+            array1[0] = carrots;
31
+            Inventory inventory = new Inventory(array1);
32
+            int expectedOutput = -1;
33
+
34
+            //when
35
+            inventory.updateQuality();
36
+            int actualOutput = carrots.getQuality();
37
+
38
+            //then
39
+            Assert.assertEquals(expectedOutput, actualOutput);
40
+
41
+
42
+        }
43
+
44
+        @Test
45
+        public void updateQuality3() {
46
+            Item sulfuras = new Item("Sulfuras, Hand of Ragnaros", 80, 80);
47
+            Item array1[] = new Item[1];
48
+            array1[0] = sulfuras;
49
+            Inventory inventory = new Inventory(array1);
50
+            int expectedOutput = 80;
51
+
52
+            //when
53
+            inventory.updateQuality();
54
+            int actualOutput = sulfuras.getQuality();
55
+
56
+            //then
57
+            Assert.assertEquals(expectedOutput, actualOutput);
58
+        }
59
+
60
+        @Test
61
+        public void updateQuality4() {
62
+            Item agedBrie = new Item ("Aged Brie", -1, 30);
63
+            Item array1[] = new Item[1];
64
+            array1[0] = agedBrie;
65
+            Inventory inventory = new Inventory(array1);
66
+            int expectedOutput = 32;
67
+
68
+            //when
69
+            inventory.updateQuality();
70
+            int actualOutput = agedBrie.getQuality();
71
+
72
+            //then
73
+            Assert.assertEquals(expectedOutput, actualOutput);
74
+        }
75
+
76
+        @Test
77
+        public void updateQuality5() {
78
+            Item bananas = new Item("Bananas", 4, 52);
79
+            Item array1[] = new Item[1];
80
+            array1[0] = bananas;
81
+            Inventory inventory = new Inventory(array1);
82
+            int expectedOutput = 0;
83
+
84
+            //when
85
+            inventory.updateQuality();
86
+            int actualOutput = bananas.getQuality();
87
+
88
+            //then
89
+           Assert.assertEquals(expectedOutput, actualOutput);
90
+        }
91
+
92
+        @Test
93
+        public void updateQuality6() {
94
+            Item backstagePass = new Item("Backstage passes to a TAFKAL80ETC concert", 8, 30);
95
+            Item array1[] = new Item[1];
96
+            array1[0] = backstagePass;
97
+            Inventory inventory = new Inventory(array1);
98
+            int expectedOutput = 32;
99
+
100
+            //when
101
+            inventory.updateQuality();
102
+            int actualOutput = backstagePass.getQuality();
103
+
104
+            //then
105
+            Assert.assertEquals(expectedOutput, actualOutput);
106
+        }
107
+
108
+        @Test
109
+        public void updateQuality7() {
110
+            Item backstagePass = new Item("Backstage passes to a TAFKAL80ETC concert", 3, 30);
111
+            Item array1[] = new Item[1];
112
+            array1[0] = backstagePass;
113
+            Inventory inventory = new Inventory(array1);
114
+            int expectedOutput = 33;
115
+
116
+            //when
117
+            inventory.updateQuality();
118
+            int actualOutput = backstagePass.getQuality();
119
+
120
+            //then
121
+            Assert.assertEquals(expectedOutput, actualOutput);
122
+        }
123
+
124
+        @Test
125
+        public void updateQuality8() {
126
+            Item backstagePass = new Item("Backstage passes to a TAFKAL80ETC concert", -1, 30);
127
+            Item array1[] = new Item[1];
128
+            array1[0] = backstagePass;
129
+            Inventory inventory = new Inventory(array1);
130
+            int expectedOutput = 0;
131
+
132
+            //when
133
+            inventory.updateQuality();
134
+            int actualOutput = backstagePass.getQuality();
135
+
136
+            //then
137
+            Assert.assertEquals(expectedOutput, actualOutput);
138
+        }
139
+
140
+        @Test
141
+        public void updateQuality9() {
142
+            Item bananas = new Item("Bananas", -1, -2);
143
+            Item array1[] = new Item[1];
144
+            array1[0] = bananas;
145
+            Inventory inventory = new Inventory(array1);
146
+            int expectedOutput = 0;
147
+
148
+            //when
149
+            inventory.updateQuality();
150
+            int actualOutput = bananas.getQuality();
151
+
152
+            //then
153
+            Assert.assertEquals(expectedOutput, actualOutput);
154
+        }
155
+
156
+
157
+
158
+
10 159
     }
11
-}
12 160