Browse Source

test 100% coverage done

Nuridalia.Hernandez 6 years ago
parent
commit
48c7709b96
1 changed files with 135 additions and 2 deletions
  1. 135
    2
      src/test/java/com/zipcodewilmington/gildedrose/InventoryTest.java

+ 135
- 2
src/test/java/com/zipcodewilmington/gildedrose/InventoryTest.java View File

@@ -3,10 +3,143 @@ package com.zipcodewilmington.gildedrose;
3 3
 import org.junit.Assert;
4 4
 import org.junit.Test;
5 5
 
6
+import java.sql.SQLOutput;
7
+
6 8
 public class InventoryTest {
9
+
10
+
11
+    Item genenetic = new Item("genetic item", 7, 25);
12
+    Item ageBrie = new Item("Aged Brie", 7, 25);
13
+    Item sulfuras = new Item("Sulfuras, Hand of Ragnaros", 15, 25);
14
+    Item backStagePasses = new Item("Backstage passes to a TAFKAL80ETC concert", 11, 20);
15
+    Item conjured = new Item("genetic item", 7, 25);
16
+    Item[] items = {genenetic, ageBrie, sulfuras, backStagePasses, conjured};
17
+
18
+    @Test
19
+    public void updateQualityTest() {
20
+        Inventory inventory = new Inventory(items);
21
+        int before = items[0].getQuality();
22
+        inventory.updateQuality();
23
+        int after = items[0].getSellIn();
24
+        Assert.assertTrue(before > after);
25
+
26
+
27
+    }
28
+
29
+
30
+    @Test
31
+    public void updateQualityTest1() {
32
+        Inventory inventory = new Inventory(items);
33
+        int before = items[0].getQuality();
34
+        inventory.updateQuality();
35
+        int after = items[0].getQuality();
36
+        Assert.assertTrue(before > after);
37
+
38
+
39
+    }
40
+
41
+    @Test
42
+    public void updateQualityTest2() {
43
+        Inventory inventory = new Inventory(items);
44
+
45
+        for (int i = 0; i < 150; i++) {
46
+            inventory.updateQuality();
47
+        }
48
+
49
+        int after = items[0].getQuality();
50
+        //System.out.println(after);
51
+        Assert.assertTrue(after >= 0);
52
+
53
+    }
54
+
55
+
56
+    @Test
57
+    public void AgeBrieQualityIcrease() {
58
+        Inventory inventory = new Inventory(items);
59
+       items[1].setQuality(50);
60
+        for (int i = 0; i < 150; i++) {
61
+            inventory.updateQuality();
62
+        }
63
+
64
+        int after = items[1].getQuality();
65
+        //System.out.println(after);
66
+
67
+        //System.out.println(after);
68
+        Assert.assertTrue(after > 0);
69
+
70
+    }
71
+
72
+    @Test
73
+    public void AgeBrieQualityEqual50() {
74
+        Inventory inventory = new Inventory(items);
75
+        items[1].setQuality(0);
76
+        for (int i = 0; i < 150; i++) {
77
+            inventory.updateQuality();
78
+        }
79
+        int expected = 50;
80
+
81
+        //System.out.println(after);
82
+        Assert.assertEquals(expected, items[1].getQuality());
83
+
84
+    }
85
+
86
+    @Test
87
+    public void testSufraQualityIcrease() {
88
+        Inventory inventory = new Inventory(items);
89
+        int before = items[2].getQuality();
90
+        for (int i = 0; i < 150; i++) {
91
+            inventory.updateQuality();
92
+        }
93
+        //quality stays the same
94
+        int after = items[2].getQuality();
95
+        // System.out.println(before); 25
96
+        // System.out.println(after); 25
97
+        Assert.assertTrue(after == before);
98
+
99
+    }
100
+
101
+    @Test
102
+    public void testBackStagePasses10() {
103
+        Inventory inventory = new Inventory(items);
104
+
105
+        for (int i = 0; i < 10; i++) ;
106
+        {
107
+            inventory.updateQuality();
108
+        }
109
+
110
+        int expected = 21;
111
+        Assert.assertEquals(expected, items[3].getQuality());
112
+    }
113
+
7 114
     @Test
8
-    public void updateQuantityTest(){
9
-        Assert.assertEquals(1, 1);
115
+    public void testBackStagePasses5() {
116
+        Inventory inventory = new Inventory(items);
117
+        items[3].setSellIn(15);
118
+        int before = items [3].getQuality();
119
+        for (int i = 0; i < 150; i++) ;
120
+        {
121
+            inventory.updateQuality();
122
+        }
123
+
124
+        int after = items[3].getQuality();
125
+        System.out.println(before);
126
+        System.out.println(after);
127
+
128
+        Assert.assertTrue(before < after);
129
+    }
130
+@Test
131
+    public void getNameTest(){
132
+        Inventory inventory = new Inventory(items);
133
+        String expected = "Sulfuras, Hand of Ragnaros";
134
+         Assert.assertEquals(expected, items [2].getName());
135
+}
136
+    @Test
137
+    public void settNameTest(){
138
+        Inventory inventory = new Inventory(items);
139
+        items[0].setName("Sailor Moon");
140
+        String expected = "Sailor Moon";
141
+        Assert.assertEquals(expected, items [0].getName());
10 142
     }
11 143
 }
12 144
 
145
+