Преглед изворни кода

tests up to and including wednesday

mpierse пре 6 година
родитељ
комит
b3746d0f14

+ 1
- 1
src/main/java/com/zipcodewilmington/froilansfarm/Holders/CropRow.java Прегледај датотеку

@@ -15,7 +15,7 @@ public class CropRow {
15 15
     }
16 16
 
17 17
     public CropRow( int numberPlanted) {
18
-        this.cropType= arbitrary;
18
+        this.cropType=arbitrary;
19 19
         this.numberPlanted=numberPlanted;
20 20
     }
21 21
 

+ 8
- 10
src/main/java/com/zipcodewilmington/froilansfarm/Holders/Farm.java Прегледај датотеку

@@ -17,8 +17,6 @@ public class Farm  {
17 17
     private CropRow row1 = new CropRow(cornStalk, 0);
18 18
     private CropRow row2 = new CropRow(tomatoPlant, 0);
19 19
     private CropRow row3 = new CropRow(cornStalk, 0);
20
-    private CropRow row4 = new CropRow(cornStalk,0);
21
-    private CropRow row5 = new CropRow(0);
22 20
     private FarmHouse house = new FarmHouse();
23 21
     private Froilan froilan = new Froilan();
24 22
     private Freelan freelan = new Freelan();
@@ -77,14 +75,6 @@ public class Farm  {
77 75
         return egg;
78 76
     }
79 77
 
80
-    public CropRow getRow5() {
81
-        return row5;
82
-    }
83
-
84
-    public CropRow getRow4() {
85
-        return row4;
86
-    }
87
-
88 78
     public CropRow getRow3() {
89 79
         return row3;
90 80
     }
@@ -105,6 +95,14 @@ public class Farm  {
105 95
         return field;
106 96
     }
107 97
 
98
+    public Tractor getTractor1() {
99
+        return tractor1;
100
+    }
101
+
102
+    public Tractor getTractor2() {
103
+        return tractor2;
104
+    }
105
+
108 106
     public void populateFarm(){
109 107
         house.addToFarmHpuse(froilan);
110 108
         house.addToFarmHpuse(froilanda);

+ 3
- 1
src/main/java/com/zipcodewilmington/froilansfarm/PlantsAndCrops/CornEar.java Прегледај датотеку

@@ -14,7 +14,9 @@ public class CornEar implements Edible {
14 14
     }
15 15
 
16 16
     public void foodIsAdded(int foodAdded) {
17
-        if(isEdible()){cornCount+=foodAdded;}
17
+        if(isEdible()){
18
+            cornCount+=foodAdded;
19
+        }
18 20
     }
19 21
 
20 22
     public void foodIsEaten(int numberEaten) {

+ 71
- 0
src/test/java/com/zipcodewilmington/froilansfarm/TuesdayTest.java Прегледај датотеку

@@ -0,0 +1,71 @@
1
+package com.zipcodewilmington.froilansfarm;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Before;
5
+import org.junit.Test;
6
+import com.zipcodewilmington.froilansfarm.Holders.Farm;
7
+
8
+public class TuesdayTest {
9
+
10
+    Farm farm;
11
+    int cornFirstCount;
12
+    int tomatoFirstCount;
13
+    int eggFirstCount;
14
+
15
+    @Before
16
+    public void setup(){
17
+        farm = new Farm();
18
+        farm.populateFarm();
19
+        farm.morningRoutine();
20
+        cornFirstCount = farm.getCorn().getFoodCount();
21
+        tomatoFirstCount = farm.getTomato().getFoodCount();
22
+        eggFirstCount = farm.getEgg().getFoodCount();
23
+        farm.getFroilanda().setIsMounted();
24
+        farm.getCropDuster().fertilize(farm.getFroilanda());
25
+    }
26
+
27
+    @Test
28
+    public void isRidingTest(){
29
+        farm.getFroilan().setIsMounted();
30
+        String actual = farm.getTractor1().ride(farm.getFroilan());
31
+        String expected = "Driving in the field today";
32
+        Assert.assertEquals(expected, actual);
33
+        farm.getFroilanda().setIsMounted();
34
+        farm.getCropDuster().fertilize(farm.getFroilanda());
35
+    }
36
+
37
+    @Test
38
+    public void harvest1Test(){
39
+        farm.getFroilan().plant(farm.getRow1(),40);
40
+        farm.getFroilan().setIsMounted();
41
+        farm.getTractor1().ride(farm.getFroilan());
42
+        farm.getTractor1().collectYeild(farm.getRow1().getNumberPlanted(), farm.getCorn(), farm.getRow1());
43
+        int secondCount = farm.getCorn().getFoodCount();
44
+        int actual =  secondCount - cornFirstCount;
45
+        int expected =40;
46
+        Assert.assertEquals(expected, actual);
47
+    }
48
+
49
+    @Test
50
+    public void harvest2Test(){
51
+        farm.getFroilan().plant(farm.getRow2(),40);
52
+        farm.getFroilan().setIsMounted();
53
+        farm.getTractor1().ride(farm.getFroilan());
54
+        farm.getTractor1().collectYeild(farm.getRow2().getNumberPlanted(), farm.getTomato(), farm.getRow2());
55
+        int secondCount = farm.getTomato().getFoodCount();
56
+        int actual =  secondCount - tomatoFirstCount;
57
+        int expected =40;
58
+        Assert.assertEquals(expected, actual);
59
+    }
60
+    @Test
61
+    public void harvest3Test(){
62
+        farm.getFroilan().plant(farm.getRow3(),40);
63
+        farm.getFroilan().setIsMounted();
64
+        farm.getTractor1().ride(farm.getFroilan());
65
+        farm.getTractor1().collectYeild(farm.getRow3().getNumberPlanted(), farm.getCorn(), farm.getRow3());
66
+        int secondCount = farm.getCorn().getFoodCount();
67
+        int actual =  secondCount - cornFirstCount;
68
+        int expected =40;
69
+        Assert.assertEquals(expected, actual);
70
+    }
71
+}

+ 25
- 0
src/test/java/com/zipcodewilmington/froilansfarm/WednesdayTest.java Прегледај датотеку

@@ -0,0 +1,25 @@
1
+package com.zipcodewilmington.froilansfarm;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Before;
5
+import org.junit.Test;
6
+import com.zipcodewilmington.froilansfarm.Holders.Farm;
7
+
8
+public class WednesdayTest {
9
+
10
+    Farm farm;
11
+
12
+    @Before
13
+    public void setup(){
14
+        farm = new Farm();
15
+        farm.populateFarm();
16
+        farm.morningRoutine();
17
+    }
18
+
19
+    @Test
20
+    public void fertilizeFieldTest(){
21
+        farm.getFreelan().setIsMounted();
22
+        farm.getCropDuster().fertilize(farm.getFreelan());
23
+        Assert.assertTrue(farm.getField().getIsFertilized());
24
+    }
25
+}