Leon Hunter пре 5 година
родитељ
комит
7ae1baa08e

+ 1
- 1
src/main/java/rocks/zipcode/quiz3a/collections/WordCounter.java Прегледај датотеку

@@ -6,7 +6,7 @@ public class WordCounter {
6 6
     public WordCounter(String... strings) {
7 7
     }
8 8
 
9
-    public static Map<String, Integer> getWordCountMap() {
9
+    public Map<String, Integer> getWordCountMap() {
10 10
         return null;
11 11
     }
12 12
 }

+ 68
- 0
src/test/java/rocks/zipcode/quiz3a/collections/wordcounter/GetWordCountMapTest.java Прегледај датотеку

@@ -1,4 +1,72 @@
1 1
 package rocks.zipcode.quiz3a.collections.wordcounter;
2 2
 
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+import rocks.zipcode.quiz3a.collections.WordCounter;
6
+
7
+import java.util.Map;
8
+
3 9
 public class GetWordCountMapTest {
10
+    @Test
11
+    public void test1() {
12
+        // given
13
+        WordCounter wordCounter = new WordCounter("Hey");
14
+        Integer expected = 1;
15
+
16
+        // when
17
+        Map<String, Integer> map = wordCounter.getWordCountMap();
18
+        Integer actual = map.get("Hey");
19
+
20
+        // then
21
+        Assert.assertEquals(expected, actual);
22
+    }
23
+
24
+    @Test
25
+    public void test2() {
26
+        // given
27
+        WordCounter wordCounter = new WordCounter("Hey", "Hey");
28
+        Integer expected = 2;
29
+
30
+        // when
31
+        Map<String, Integer> map = wordCounter.getWordCountMap();
32
+        Integer actual = map.get("Hey");
33
+
34
+        // then
35
+        Assert.assertEquals(expected, actual);
36
+    }
37
+
38
+    @Test
39
+    public void test3() {
40
+        // given
41
+        WordCounter wordCounter = new WordCounter("Hey", "Hey", "Hello");
42
+        Integer expectedHey = 2;
43
+        Integer expectedHello = 1;
44
+
45
+        // when
46
+        Map<String, Integer> map = wordCounter.getWordCountMap();
47
+        Integer actualHey = map.get("Hey");
48
+        Integer actualHello = map.get("Hello");
49
+
50
+        // then
51
+        Assert.assertEquals(expectedHey, actualHey);
52
+        Assert.assertEquals(expectedHello, actualHello);
53
+    }
54
+
55
+
56
+    @Test
57
+    public void test4() {
58
+        // given
59
+        WordCounter wordCounter = new WordCounter("Hey", "Hey", "Hello", "Hello", "Hello");
60
+        Integer expectedHey = 2;
61
+        Integer expectedHello = 3;
62
+
63
+        // when
64
+        Map<String, Integer> map = wordCounter.getWordCountMap();
65
+        Integer actualHey = map.get("Hey");
66
+        Integer actualHello = map.get("Hello");
67
+
68
+        // then
69
+        Assert.assertEquals(expectedHey, actualHey);
70
+        Assert.assertEquals(expectedHello, actualHello);
71
+    }
4 72
 }