11import org .junit .Ignore ;
2+ import org .junit .Before ;
23import org .junit .Test ;
34
45import java .util .List ;
910import static org .junit .Assert .assertThat ;
1011
1112public final class DiamondPrinterTest {
12-
13+ private DiamondPrinter diamondPrinter ;
14+
15+ @ Before
16+ public void setUp () {
17+ diamondPrinter = new DiamondPrinter ();
18+ }
19+
1320 @ Test
1421 public void testOneByOneDiamond () {
15- List <String > output = new DiamondPrinter () .printToList ('A' );
22+ List <String > output = diamondPrinter .printToList ('A' );
1623 assertThat (output , is (singletonList ("A" )));
1724 }
1825
1926 @ Ignore
2027 @ Test
2128 public void testTwoByTwoDiamond () {
22- List <String > output = new DiamondPrinter () .printToList ('B' );
29+ List <String > output = diamondPrinter .printToList ('B' );
2330 assertThat (output , is (asList (" A " ,
2431 "B B" ,
2532 " A " )));
@@ -28,7 +35,7 @@ public void testTwoByTwoDiamond() {
2835 @ Ignore
2936 @ Test
3037 public void testThreeByThreeDiamond () {
31- List <String > output = new DiamondPrinter () .printToList ('C' );
38+ List <String > output = diamondPrinter .printToList ('C' );
3239 assertThat (output , is (asList (" A " ,
3340 " B B " ,
3441 "C C" ,
@@ -39,7 +46,7 @@ public void testThreeByThreeDiamond() {
3946 @ Ignore
4047 @ Test
4148 public void testFiveByFiveDiamond () {
42- List <String > output = new DiamondPrinter () .printToList ('E' );
49+ List <String > output = diamondPrinter .printToList ('E' );
4350 assertThat (output , is (asList (" A " ,
4451 " B B " ,
4552 " C C " ,
@@ -54,7 +61,7 @@ public void testFiveByFiveDiamond() {
5461 @ Ignore
5562 @ Test
5663 public void testFullDiamond () {
57- List <String > output = new DiamondPrinter () .printToList ('Z' );
64+ List <String > output = diamondPrinter .printToList ('Z' );
5865 assertThat (output , is (asList (" A " ,
5966 " B B " ,
6067 " C C " ,
0 commit comments