Pārlūkot izejas kodu

{stuck on tests, but still going}

Jacqueline Joson 6 gadus atpakaļ
vecāks
revīzija
3c81a66851

+ 76
- 3
src/test/java/com/zipcodewilmington/gildedrose/InventoryTest.java Parādīt failu

@@ -1,12 +1,85 @@
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
 
7
+import java.util.ArrayList;
8
+
6 9
 public class InventoryTest {
10
+    Item sulfaras = new Item("Sulfuras, Hand of Ragnaros", 5, 10);
11
+    Item agedBrie = new Item("Aged Brie", 10, 20);
12
+    Item backstagePass = new Item("Backstage passes to a TAFKAL80ETC concert", 10, 30);
13
+    Item apple = new Item("Apple", 10, 20);
14
+    Item strawberry = new Item ("Strawberry", 0 , 55);
15
+    Inventory inventory;
16
+
17
+    @Before
18
+    public void setup() {
19
+        Item[] itemsArray = {sulfaras, agedBrie, backstagePass, apple};
20
+        inventory = new Inventory(itemsArray);
21
+
22
+    }
23
+
24
+    @Test
25
+    public void testSetAndUpdateQualityForNormalItem() {
26
+        int expected = apple.getQuality() - 1;
27
+
28
+        //when
29
+        inventory.updateQuality();
30
+
31
+        //then
32
+        Assert.assertEquals(expected, apple.getQuality());
33
+    }
34
+
7 35
     @Test
8
-    public void updateQuantityTest(){
9
-        Assert.assertEquals(1, 1);
36
+    public void testForSulfaras() {
37
+
38
+        int expected = sulfaras.getQuality();
39
+
40
+        //when
41
+        inventory.updateQuality();
42
+
43
+        //then
44
+        Assert.assertEquals(expected, sulfaras.getQuality());
45
+    }
46
+
47
+    @Test
48
+    public void testBackstagePassSell() {
49
+        Item backstagePass = new Item("Backstage passes to a TAFKAL80ETC concert", 5, 2);
50
+        int expected = 2 ;
51
+
52
+        //when
53
+        inventory.updateQuality();
54
+
55
+        //then
56
+        Assert.assertEquals(expected, backstagePass.getQuality());
57
+    }
58
+
59
+    @Test
60
+    public void testBackstagePassQuality() {
61
+        //given
62
+        Item backstagePass = new Item("Backstage passes to a TAFKAL80ETC concert", 12, 55);
63
+        
64
+        int expected = backstagePass.getQuality();
65
+
66
+            //when
67
+        inventory.updateQuality();
68
+
69
+            //then
70
+        Assert.assertEquals(expected, backstagePass.getQuality());
71
+
72
+        }
73
+       @Test
74
+    public void testSellInForNormalItem() {
75
+        Item apple = new Item("Apple", -2, 20);
76
+        int expected = apple.getQuality();
77
+
78
+        //when
79
+        inventory.updateQuality();
80
+
81
+        //then
82
+        Assert.assertEquals(expected, apple.getQuality());
83
+    }
10 84
     }
11
-}
12 85