Leon Hunter 5 years ago
parent
commit
ee506d95d5

+ 2
- 2
src/test/java/rocks/zipcode/quiz3a/fundamentals/stringutils/LowerCaseMiddleCharacterTest.java View File

12
         String expected = "o";
12
         String expected = "o";
13
 
13
 
14
         // when
14
         // when
15
-        String actual = StringUtils.capitalizeMiddleCharacter(input);
15
+        String actual = StringUtils.lowerCaseMiddleCharacter(input);
16
 
16
 
17
         // then
17
         // then
18
         Assert.assertEquals(expected, actual);
18
         Assert.assertEquals(expected, actual);
25
         String expected = "OoO";
25
         String expected = "OoO";
26
 
26
 
27
         // when
27
         // when
28
-        String actual = StringUtils.capitalizeMiddleCharacter(input);
28
+        String actual = StringUtils.lowerCaseMiddleCharacter(input);
29
 
29
 
30
         // then
30
         // then
31
         Assert.assertEquals(expected, actual);
31
         Assert.assertEquals(expected, actual);

+ 36
- 3
src/test/java/rocks/zipcode/quiz3a/objectorientation/food/GetSpiceCountTest.java View File

3
 import org.junit.Assert;
3
 import org.junit.Assert;
4
 import org.junit.Test;
4
 import org.junit.Test;
5
 import rocks.zipcode.quiz3a.collections.Food;
5
 import rocks.zipcode.quiz3a.collections.Food;
6
+import rocks.zipcode.quiz3a.objectorientation.Curry;
7
+import rocks.zipcode.quiz3a.objectorientation.Ginger;
6
 import rocks.zipcode.quiz3a.objectorientation.Pepper;
8
 import rocks.zipcode.quiz3a.objectorientation.Pepper;
7
 import rocks.zipcode.quiz3a.objectorientation.Spice;
9
 import rocks.zipcode.quiz3a.objectorientation.Spice;
8
 
10
 
9
 import java.util.Map;
11
 import java.util.Map;
12
+import java.util.function.Supplier;
10
 
13
 
11
 public class GetSpiceCountTest {
14
 public class GetSpiceCountTest {
12
     @Test
15
     @Test
13
     public void test1() {
16
     public void test1() {
17
+        test(5, Pepper::new);
18
+    }
19
+
20
+    @Test
21
+    public void test2() {
22
+        test(10, Pepper::new);
23
+    }
24
+
25
+    @Test
26
+    public void test3() {
27
+        test(3, Curry::new);
28
+    }
29
+
30
+
31
+    @Test
32
+    public void test4() {
33
+        test(6, Curry::new);
34
+    }
35
+
36
+    @Test
37
+    public void test5() {
38
+        test(2, Ginger::new);
39
+    }
40
+
41
+    @Test
42
+    public void test6() {
43
+        test(4, Ginger::new);
44
+    }
45
+
46
+    public void test(Integer amountOfIngredients, Supplier<?> ingredientConstructor) {
14
         // given
47
         // given
48
+        Integer expected = amountOfIngredients;
15
         Food food = new Food();
49
         Food food = new Food();
16
-        Integer expected = 5;
17
         Spice pepper = null;
50
         Spice pepper = null;
18
-        for (int i = 0; i < expected; i++) {
19
-            pepper = (Spice)new Pepper();
51
+        for (int i = 0; i < amountOfIngredients; i++) {
52
+            pepper = (Spice) ingredientConstructor.get();
20
             food.applySpice(pepper);
53
             food.applySpice(pepper);
21
         }
54
         }
22
 
55