|
@@ -3,20 +3,53 @@ package rocks.zipcode.quiz3a.objectorientation.food;
|
3
|
3
|
import org.junit.Assert;
|
4
|
4
|
import org.junit.Test;
|
5
|
5
|
import rocks.zipcode.quiz3a.collections.Food;
|
|
6
|
+import rocks.zipcode.quiz3a.objectorientation.Curry;
|
|
7
|
+import rocks.zipcode.quiz3a.objectorientation.Ginger;
|
6
|
8
|
import rocks.zipcode.quiz3a.objectorientation.Pepper;
|
7
|
9
|
import rocks.zipcode.quiz3a.objectorientation.Spice;
|
8
|
10
|
|
9
|
11
|
import java.util.Map;
|
|
12
|
+import java.util.function.Supplier;
|
10
|
13
|
|
11
|
14
|
public class GetSpiceCountTest {
|
12
|
15
|
@Test
|
13
|
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
|
47
|
// given
|
|
48
|
+ Integer expected = amountOfIngredients;
|
15
|
49
|
Food food = new Food();
|
16
|
|
- Integer expected = 5;
|
17
|
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
|
53
|
food.applySpice(pepper);
|
21
|
54
|
}
|
22
|
55
|
|