Sfoglia il codice sorgente

Update ScrabbleScoreTest

Ahchuang 8 anni fa
parent
commit
0eadda06cc
1 ha cambiato i file con 71 aggiunte e 29 eliminazioni
  1. 71
    29
      exercises/scrabble-score/src/test/java/ScrabbleScoreTest.java

+ 71
- 29
exercises/scrabble-score/src/test/java/ScrabbleScoreTest.java Vedi File

@@ -1,44 +1,86 @@
1
+import org.junit.Ignore;
1 2
 import org.junit.Test;
2
-import org.junit.runner.RunWith;
3
-import org.junit.runners.Parameterized;
4
-
5
-import java.util.Arrays;
6
-import java.util.Collection;
7 3
 
8 4
 import static org.junit.Assert.assertEquals;
9 5
 
10
-@RunWith(Parameterized.class)
11 6
 public class ScrabbleScoreTest {
12 7
 
13
-    private String scrabbleInput;
14
-    private int scrabbleScore;
8
+    private Scrabble scrabble;
9
+
10
+    @Test
11
+    public void testALowerCaseLetter() {
12
+        scrabble = new Scrabble("a");
13
+        assertEquals(1, scrabble.getScore());
14
+    }
15
+
16
+    @Ignore("Remove to run test")
17
+    @Test
18
+    public void testAUpperCaseLetter() {
19
+        scrabble = new Scrabble("A");
20
+        assertEquals(1, scrabble.getScore());
21
+    }
22
+
23
+    @Ignore("Remove to run test")
24
+    @Test
25
+    public void testAValuableLetter() {
26
+        scrabble = new Scrabble("f");
27
+        assertEquals(4, scrabble.getScore());
28
+    }
15 29
 
16
-    @Parameterized.Parameters(name = "{index}: expected scrabble score for \"{0}\" to be {1}")
17
-    public static Collection<Object[]> data() {
18
-        return Arrays.asList(new Object[][]{
19
-                {"a", 1},
20
-                {"A", 1},
21
-                {"f", 4},
22
-                {"at", 2},
23
-                {"zoo", 12},
24
-                {"street", 6},
25
-                {"quirky", 22},
26
-                {"OxyphenButazone", 41},
27
-                {"pinata", 8},
28
-                {"", 0},
29
-                {"abcdefghijklmnopqrstuvwxyz", 87},
30
-        });
30
+    @Ignore("Remove to run test")
31
+    @Test
32
+    public void testAShortWord() {
33
+        scrabble = new Scrabble("at");
34
+        assertEquals(2, scrabble.getScore());
35
+    }
36
+
37
+    @Ignore("Remove to run test")
38
+    @Test
39
+    public void testAShortValuableWord() {
40
+        scrabble = new Scrabble("zoo");
41
+        assertEquals(12, scrabble.getScore());
31 42
     }
32 43
 
33
-    public ScrabbleScoreTest(String scrabbleInput, int scrabbleScore) {
34
-        this.scrabbleInput = scrabbleInput;
35
-        this.scrabbleScore = scrabbleScore;
44
+    @Ignore("Remove to run test")
45
+    @Test
46
+    public void testAMediumWord() {
47
+        scrabble = new Scrabble("street");
48
+        assertEquals(6, scrabble.getScore());
49
+    }
50
+
51
+    @Ignore("Remove to run test")
52
+    @Test
53
+    public void testAMediumValuableWord() {
54
+        scrabble = new Scrabble("quirky");
55
+        assertEquals(22, scrabble.getScore());
56
+    }
57
+
58
+    @Ignore("Remove to run test")
59
+    @Test
60
+    public void testALongMixCaseWord() {
61
+        scrabble = new Scrabble("OxyphenButazone");
62
+        assertEquals(41, scrabble.getScore());
63
+    }
64
+
65
+    @Ignore("Remove to run test")
66
+    @Test
67
+    public void testAEnglishLikeWord() {
68
+        scrabble = new Scrabble("pinata");
69
+        assertEquals(8, scrabble.getScore());
70
+    }
71
+
72
+    @Ignore("Remove to run test")
73
+    @Test
74
+    public void testAnEmptyInput() {
75
+        scrabble = new Scrabble("");
76
+        assertEquals(0, scrabble.getScore());
36 77
     }
37 78
 
79
+    @Ignore("Remove to run test")
38 80
     @Test
39
-    public void test() {
40
-        Scrabble scrabble = new Scrabble(scrabbleInput);
41
-        assertEquals(scrabbleScore, scrabble.getScore());
81
+    public void testEntireAlphabetAvailable() {
82
+        scrabble = new Scrabble("abcdefghijklmnopqrstuvwxyz");
83
+        assertEquals(87, scrabble.getScore());
42 84
     }
43 85
 
44 86
 }