Sfoglia il codice sorgente

Merge pull request #399 from morrme/patch-1

Fixed issue #359
FridaTveit 9 anni fa
parent
commit
5402392336
1 ha cambiato i file con 13 aggiunte e 6 eliminazioni
  1. 13
    6
      exercises/diamond/src/test/java/DiamondPrinterTest.java

+ 13
- 6
exercises/diamond/src/test/java/DiamondPrinterTest.java Vedi File

1
 import org.junit.Ignore;
1
 import org.junit.Ignore;
2
+import org.junit.Before;
2
 import org.junit.Test;
3
 import org.junit.Test;
3
 
4
 
4
 import java.util.List;
5
 import java.util.List;
9
 import static org.junit.Assert.assertThat;
10
 import static org.junit.Assert.assertThat;
10
 
11
 
11
 public final class DiamondPrinterTest {
12
 public final class DiamondPrinterTest {
12
-
13
+    private DiamondPrinter diamondPrinter;
14
+    
15
+    @Before
16
+    public void setUp() {
17
+        diamondPrinter = new DiamondPrinter();
18
+    }
19
+        
13
     @Test
20
     @Test
14
     public void testOneByOneDiamond() {
21
     public void testOneByOneDiamond() {
15
-        List<String> output = new DiamondPrinter().printToList('A');
22
+        List<String> output = diamondPrinter.printToList('A');
16
         assertThat(output, is(singletonList("A")));
23
         assertThat(output, is(singletonList("A")));
17
     }
24
     }
18
 
25
 
19
     @Ignore
26
     @Ignore
20
     @Test
27
     @Test
21
     public void testTwoByTwoDiamond() {
28
     public void testTwoByTwoDiamond() {
22
-        List<String> output = new DiamondPrinter().printToList('B');
29
+        List<String> output = diamondPrinter.printToList('B');
23
         assertThat(output, is(asList(" A ",
30
         assertThat(output, is(asList(" A ",
24
                                      "B B",
31
                                      "B B",
25
                                      " A ")));
32
                                      " A ")));
28
     @Ignore
35
     @Ignore
29
     @Test
36
     @Test
30
     public void testThreeByThreeDiamond() {
37
     public void testThreeByThreeDiamond() {
31
-        List<String> output = new DiamondPrinter().printToList('C');
38
+        List<String> output = diamondPrinter.printToList('C');
32
         assertThat(output, is(asList("  A  ",
39
         assertThat(output, is(asList("  A  ",
33
                                      " B B ",
40
                                      " B B ",
34
                                      "C   C",
41
                                      "C   C",
39
     @Ignore
46
     @Ignore
40
     @Test
47
     @Test
41
     public void testFiveByFiveDiamond() {
48
     public void testFiveByFiveDiamond() {
42
-        List<String> output = new DiamondPrinter().printToList('E');
49
+        List<String> output = diamondPrinter.printToList('E');
43
         assertThat(output, is(asList("    A    ",
50
         assertThat(output, is(asList("    A    ",
44
                                      "   B B   ",
51
                                      "   B B   ",
45
                                      "  C   C  ",
52
                                      "  C   C  ",
54
     @Ignore
61
     @Ignore
55
     @Test
62
     @Test
56
     public void testFullDiamond() {
63
     public void testFullDiamond() {
57
-        List<String> output = new DiamondPrinter().printToList('Z');
64
+        List<String> output = diamondPrinter.printToList('Z');
58
         assertThat(output, is(asList("                         A                         ",
65
         assertThat(output, is(asList("                         A                         ",
59
                                      "                        B B                        ",
66
                                      "                        B B                        ",
60
                                      "                       C   C                       ",
67
                                      "                       C   C                       ",