Bläddra i källkod

Test cover 35% of lines in code

Akeem Cherry 6 år sedan
förälder
incheckning
da31c70406

+ 1
- 13
src/main/java/com/zipcodewilmington/gildedrose/Inventory.java Visa fil

@@ -22,14 +22,7 @@ public class Inventory {
22 22
             } else {
23 23
                 if (items[i].getQuality() < 50) {
24 24
                     items[i].setQuality(items[i].getQuality() + 1);
25
-
26 25
                     if (items[i].getName() == "Backstage passes to a TAFKAL80ETC concert") {
27
-                        if (items[i].getSellIn() < 11) {
28
-                            if (items[i].getQuality() < 50) {
29
-                                items[i].setQuality(items[i].getQuality() + 1);
30
-                            }
31
-                        }
32
-
33 26
                         if (items[i].getSellIn() < 6) {
34 27
                             if (items[i].getQuality() < 50) {
35 28
                                 items[i].setQuality(items[i].getQuality() + 1);
@@ -52,12 +45,7 @@ public class Inventory {
52 45
                             }
53 46
                         }
54 47
                     } else {
55
-                        items[i].setQuality(items[i].getQuality()
56
-                                - items[i].getQuality());
57
-                    }
58
-                } else {
59
-                    if (items[i].getQuality() < 50) {
60
-                        items[i].setQuality(items[i].getQuality() + 1);
48
+                        items[i].setQuality(0);
61 49
                     }
62 50
                 }
63 51
             }

+ 6
- 0
src/main/java/com/zipcodewilmington/gildedrose/Item.java Visa fil

@@ -13,26 +13,32 @@ public class Item {
13 13
     }
14 14
 
15 15
     public String getName() {
16
+
16 17
         return name;
17 18
     }
18 19
 
19 20
     public void setName(String name) {
21
+
20 22
         this.name = name;
21 23
     }
22 24
 
23 25
     public int getSellIn() {
26
+
24 27
         return sellIn;
25 28
     }
26 29
 
27 30
     public void setSellIn(int sellIn) {
31
+
28 32
         this.sellIn = sellIn;
29 33
     }
30 34
 
31 35
     public int getQuality() {
36
+
32 37
         return quality;
33 38
     }
34 39
 
35 40
     public void setQuality(int quality) {
41
+
36 42
         this.quality = quality;
37 43
     }
38 44
 }

+ 53
- 0
src/test/java/com/zipcodewilmington/gildedrose/InventoryTest.java Visa fil

@@ -6,7 +6,60 @@ import org.junit.Test;
6 6
 public class InventoryTest {
7 7
     @Test
8 8
     public void updateQuantityTest(){
9
+        Item item = new Item("Sulfuras", 1, 1);
9 10
         Assert.assertEquals(1, 1);
10 11
     }
12
+
13
+    @Test
14
+    public void getNameTest(){
15
+        Item tape = new Item("Some new tape",47,55);
16
+        String expectedTapeName = "Some new tape";
17
+        String actualTapeName = tape.getName();
18
+        Assert.assertEquals(expectedTapeName, actualTapeName);
19
+    }
20
+
21
+    @Test
22
+    public void setNameTest(){
23
+        Item tape = new Item("Some new tape", 47,55);
24
+        String expectedTapeName = "New Tape";
25
+        tape.setName("New Tape");
26
+        String actualTapeName = tape.getName();
27
+        Assert.assertEquals(expectedTapeName, actualTapeName);
28
+    }
29
+
30
+    @Test
31
+    public void getSellInTest(){
32
+        Item tape = new Item("Some new tape", 47,55);
33
+        int expectedSellIn = 47;
34
+        int actualSellIn = tape.getSellIn();
35
+        Assert.assertEquals(expectedSellIn, actualSellIn);
36
+    }
37
+
38
+    @Test
39
+    public void setSellInTest(){
40
+        Item tape = new Item("Some new tape", 47,55);
41
+        int expectedSellIn = 47;
42
+        tape.setSellIn(47);
43
+        int actualSellIn = tape.getSellIn();
44
+        Assert.assertEquals(expectedSellIn, actualSellIn);
45
+    }
46
+
47
+    @Test
48
+    public void getQualityTest(){
49
+        Item tape = new Item("Some new tape", 47,55);
50
+        int expectedQuality = 55;
51
+        int actualQuality = tape.getQuality();
52
+        Assert.assertEquals(expectedQuality, actualQuality);
53
+    }
54
+
55
+    @Test
56
+    public void setQualityTest(){
57
+        Item tape = new Item("Some new tape", 47,55);
58
+        int expectedQuality = 55;
59
+        tape.setQuality(55);
60
+        int actualQuality = tape.getQuality();
61
+        Assert.assertEquals(expectedQuality, actualQuality);
62
+    }
63
+
11 64
 }
12 65