thulasi 6 лет назад
Родитель
Сommit
0cbcfe63cd

+ 5
- 0
src/main/java/com/zipcodewilmington/gildedrose/Inventory.java Просмотреть файл

@@ -63,4 +63,9 @@ public class Inventory {
63 63
             }
64 64
         }
65 65
     }
66
+
67
+    public Item[] getItems(){
68
+
69
+        return this.items;
70
+    }
66 71
 }

+ 122
- 2
src/test/java/com/zipcodewilmington/gildedrose/InventoryTest.java Просмотреть файл

@@ -1,12 +1,132 @@
1 1
 package com.zipcodewilmington.gildedrose;
2 2
 
3 3
 import org.junit.Assert;
4
+import org.junit.Before;
4 5
 import org.junit.Test;
5 6
 
6 7
 public class InventoryTest {
8
+
9
+    Inventory inventory;
10
+
11
+    @Before
12
+    public void setUp(){
13
+
14
+        Item brie = new Item("Aged Brie", 2, 4);
15
+        Item brie2 = new Item("Aged Brie", -5, 30);
16
+        Item passes = new Item("Backstage passes to a TAFKAL80ETC concert", 4, 45);
17
+        Item passes2 = new Item("Backstage passes to a TAFKAL80ETC concert", 10, 40);
18
+        Item passes3 = new Item("Backstage passes to a TAFKAL80ETC concert", 15, 42);
19
+        Item passes4 = new Item("Backstage passes to a TAFKAL80ETC concert", -3, 42);
20
+        Item sulfuras = new Item("Sulfuras, Hand of Ragnaros", 3,55);
21
+        Item conjured = new Item("conjured", 5, 20);
22
+        Item genericItem = new Item("Generic Item", 6, 40);
23
+
24
+        Item[] items = new Item[10];
25
+        items[0] = brie;
26
+        items[1] = brie2;
27
+        items[2] = passes;
28
+        items[3] = passes2;
29
+        items[4] = passes3;
30
+        items[5] = passes4;
31
+        items[6] = sulfuras;
32
+        items[7] = conjured;
33
+        items[8] = genericItem;
34
+
35
+        inventory = new Inventory(items);
36
+    }
37
+
38
+    @Test
39
+    public void testBrieQuantity(){
40
+        inventory.updateQuality();
41
+        Item[] items = inventory.getItems();
42
+        int actual = items[0].getQuality();
43
+
44
+        Assert.assertEquals(5, actual);
45
+    }
46
+
47
+    @Test
48
+    public void testBrie2(){
49
+        inventory.updateQuality();
50
+        Item[] items = inventory.getItems();
51
+        int actual = items[1].getQuality();
52
+
53
+        Assert.assertEquals(32, actual);
54
+    }
55
+    @Test
56
+    public void testPassSellin_Lessthan5(){
57
+        inventory.updateQuality();
58
+        Item[] items = inventory.getItems();
59
+        int actual = items[2].getQuality();
60
+
61
+        Assert.assertEquals(48,actual);
62
+    }
63
+
64
+    @Test
65
+    public void testPassSellin_Lessthan11(){
66
+        inventory.updateQuality();
67
+        Item[] items = inventory.getItems();
68
+        int actual = items[3].getQuality();
69
+
70
+        Assert.assertEquals(42,actual);
71
+    }
72
+
73
+    @Test
74
+    public void testPassSellin_Greaterthan11(){
75
+        inventory.updateQuality();
76
+        Item[] items = inventory.getItems();
77
+        int actual = items[4].getQuality();
78
+
79
+        Assert.assertEquals(43,actual);
80
+    }
81
+
82
+    @Test
83
+    public void testPassSellin_Lessthan0(){
84
+        inventory.updateQuality();
85
+        Item[] items = inventory.getItems();
86
+        int actual = items[5].getQuality();
87
+
88
+        Assert.assertEquals(0,actual);
89
+    }
90
+
91
+    @Test
92
+    public void testSulphuras(){
93
+        inventory.updateQuality();
94
+        Item[] items = inventory.getItems();
95
+        int actual = items[6].getQuality();
96
+
97
+        Assert.assertEquals(55,actual);
98
+    }
99
+
100
+    @Test
101
+    public void testConjured(){
102
+        inventory.updateQuality();
103
+        Item[] items = inventory.getItems();
104
+        int actual = items[7].getQuality();
105
+
106
+        Assert.assertEquals(19,actual);
107
+    }
108
+
109
+
110
+    @Test
111
+    public void testGenericItem(){
112
+        inventory.updateQuality();
113
+        Item[] items = inventory.getItems();
114
+        int actual = items[8].getQuality();
115
+
116
+        Assert.assertEquals(39,actual);
117
+    }
118
+
119
+
120
+    @Test
121
+    public void testSetName(){
122
+        Item[] items = inventory.getItems();
123
+        items[8].setName("General");
124
+        Assert.assertEquals("General",items[8].getName());;
125
+    }
126
+
7 127
     @Test
8
-    public void updateQuantityTest(){
9
-        Assert.assertEquals(1, 1);
128
+    public void checkQuantityTest(){
129
+        Assert.assertEquals(1,1);
10 130
     }
11 131
 }
12 132