tracks/java/exercises/minesweeper/src/test/java/MinesweeperBoardTest.java in trackler-2.1.0.48 vs tracks/java/exercises/minesweeper/src/test/java/MinesweeperBoardTest.java in trackler-2.1.0.49

- old
+ new

@@ -1,44 +1,36 @@ import org.junit.Ignore; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import java.util.Arrays; import java.util.Collections; import java.util.List; import static org.junit.Assert.assertEquals; +/* + * version: 1.0.0 + */ public class MinesweeperBoardTest { - /* - * See https://github.com/junit-team/junit4/wiki/Rules for information on JUnit Rules in general and - * ExpectedExceptions in particular. - */ - @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Test public void testInputBoardWithNoRowsAndNoColumns() { final List<String> inputBoard = Collections.emptyList(); - final List<String> expectedAnnotatedRepresentation = Collections.emptyList(); - final List<String> actualAnnotatedRepresentation - = new MinesweeperBoard(inputBoard).getAnnotatedRepresentation(); + final List<String> expectedNumberedBoard = Collections.emptyList(); + final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers(); - assertEquals(expectedAnnotatedRepresentation, actualAnnotatedRepresentation); + assertEquals(expectedNumberedBoard, actualNumberedBoard); } @Ignore("Remove to run test") @Test public void testInputBoardWithOneRowAndNoColumns() { final List<String> inputBoard = Collections.singletonList(""); - final List<String> expectedAnnotatedRepresentation = Collections.singletonList(""); - final List<String> actualAnnotatedRepresentation - = new MinesweeperBoard(inputBoard).getAnnotatedRepresentation(); + final List<String> expectedNumberedBoard = Collections.singletonList(""); + final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers(); - assertEquals(expectedAnnotatedRepresentation, actualAnnotatedRepresentation); + assertEquals(expectedNumberedBoard, actualNumberedBoard); } @Ignore("Remove to run test") @Test public void testInputBoardWithNoMines() { @@ -46,20 +38,19 @@ " ", " ", " " ); - final List<String> expectedAnnotatedRepresentation = Arrays.asList( + final List<String> expectedNumberedBoard = Arrays.asList( " ", " ", " " ); - final List<String> actualAnnotatedRepresentation - = new MinesweeperBoard(inputBoard).getAnnotatedRepresentation(); + final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers(); - assertEquals(expectedAnnotatedRepresentation, actualAnnotatedRepresentation); + assertEquals(expectedNumberedBoard, actualNumberedBoard); } @Ignore("Remove to run test") @Test public void testInputBoardWithOnlyMines() { @@ -67,20 +58,19 @@ "***", "***", "***" ); - final List<String> expectedAnnotatedRepresentation = Arrays.asList( + final List<String> expectedNumberedBoard = Arrays.asList( "***", "***", "***" ); - final List<String> actualAnnotatedRepresentation - = new MinesweeperBoard(inputBoard).getAnnotatedRepresentation(); + final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers(); - assertEquals(expectedAnnotatedRepresentation, actualAnnotatedRepresentation); + assertEquals(expectedNumberedBoard, actualNumberedBoard); } @Ignore("Remove to run test") @Test public void testInputBoardWithSingleMineAtCenter() { @@ -88,20 +78,19 @@ " ", " * ", " " ); - final List<String> expectedAnnotatedRepresentation = Arrays.asList( + final List<String> expectedNumberedBoard = Arrays.asList( "111", "1*1", "111" ); - final List<String> actualAnnotatedRepresentation - = new MinesweeperBoard(inputBoard).getAnnotatedRepresentation(); + final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers(); - assertEquals(expectedAnnotatedRepresentation, actualAnnotatedRepresentation); + assertEquals(expectedNumberedBoard, actualNumberedBoard); } @Ignore("Remove to run test") @Test public void testInputBoardWithMinesAroundPerimeter() { @@ -109,54 +98,51 @@ "***", "* *", "***" ); - final List<String> expectedAnnotatedRepresentation = Arrays.asList( + final List<String> expectedNumberedBoard = Arrays.asList( "***", "*8*", "***" ); - final List<String> actualAnnotatedRepresentation - = new MinesweeperBoard(inputBoard).getAnnotatedRepresentation(); + final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers(); - assertEquals(expectedAnnotatedRepresentation, actualAnnotatedRepresentation); + assertEquals(expectedNumberedBoard, actualNumberedBoard); } @Ignore("Remove to run test") @Test public void testInputBoardWithSingleRowAndTwoMines() { final List<String> inputBoard = Collections.singletonList( " * * " ); - final List<String> expectedAnnotatedRepresentation = Collections.singletonList( + final List<String> expectedNumberedBoard = Collections.singletonList( "1*2*1" ); - final List<String> actualAnnotatedRepresentation - = new MinesweeperBoard(inputBoard).getAnnotatedRepresentation(); + final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers(); - assertEquals(expectedAnnotatedRepresentation, actualAnnotatedRepresentation); + assertEquals(expectedNumberedBoard, actualNumberedBoard); } @Ignore("Remove to run test") @Test public void testInputBoardWithSingleRowAndTwoMinesAtEdges() { final List<String> inputBoard = Collections.singletonList( "* *" ); - final List<String> expectedAnnotatedRepresentation = Collections.singletonList( + final List<String> expectedNumberedBoard = Collections.singletonList( "*1 1*" ); - final List<String> actualAnnotatedRepresentation - = new MinesweeperBoard(inputBoard).getAnnotatedRepresentation(); + final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers(); - assertEquals(expectedAnnotatedRepresentation, actualAnnotatedRepresentation); + assertEquals(expectedNumberedBoard, actualNumberedBoard); } @Ignore("Remove to run test") @Test public void testInputBoardWithSingleColumnAndTwoMines() { @@ -166,22 +152,21 @@ " ", "*", " " ); - final List<String> expectedAnnotatedRepresentation = Arrays.asList( + final List<String> expectedNumberedBoard = Arrays.asList( "1", "*", "2", "*", "1" ); - final List<String> actualAnnotatedRepresentation - = new MinesweeperBoard(inputBoard).getAnnotatedRepresentation(); + final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers(); - assertEquals(expectedAnnotatedRepresentation, actualAnnotatedRepresentation); + assertEquals(expectedNumberedBoard, actualNumberedBoard); } @Ignore("Remove to run test") @Test public void testInputBoardWithSingleColumnAndTwoMinesAtEdges() { @@ -191,22 +176,21 @@ " ", " ", "*" ); - final List<String> expectedAnnotatedRepresentation = Arrays.asList( + final List<String> expectedNumberedBoard = Arrays.asList( "*", "1", " ", "1", "*" ); - final List<String> actualAnnotatedRepresentation - = new MinesweeperBoard(inputBoard).getAnnotatedRepresentation(); + final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers(); - assertEquals(expectedAnnotatedRepresentation, actualAnnotatedRepresentation); + assertEquals(expectedNumberedBoard, actualNumberedBoard); } @Ignore("Remove to run test") @Test public void testInputBoardWithMinesInCross() { @@ -216,22 +200,21 @@ "*****", " * ", " * " ); - final List<String> expectedAnnotatedRepresentation = Arrays.asList( + final List<String> expectedNumberedBoard = Arrays.asList( " 2*2 ", "25*52", "*****", "25*52", " 2*2 " ); - final List<String> actualAnnotatedRepresentation - = new MinesweeperBoard(inputBoard).getAnnotatedRepresentation(); + final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers(); - assertEquals(expectedAnnotatedRepresentation, actualAnnotatedRepresentation); + assertEquals(expectedNumberedBoard, actualNumberedBoard); } @Ignore("Remove to run test") @Test public void testLargeInputBoard() { @@ -242,54 +225,20 @@ " * *", " * * ", " " ); - final List<String> expectedAnnotatedRepresentation = Arrays.asList( + final List<String> expectedNumberedBoard = Arrays.asList( "1*22*1", "12*322", " 123*2", "112*4*", "1*22*2", "111111" ); - final List<String> actualAnnotatedRepresentation - = new MinesweeperBoard(inputBoard).getAnnotatedRepresentation(); + final List<String> actualNumberedBoard = new MinesweeperBoard(inputBoard).withNumbers(); - assertEquals(expectedAnnotatedRepresentation, actualAnnotatedRepresentation); - } - - @Ignore("Remove to run test") - @Test - public void testNullInputBoardIsRejected() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Input board may not be null."); - - new MinesweeperBoard(null); - } - - @Ignore("Remove to run test") - @Test - public void testInputBoardWithInvalidSymbolsIsRejected() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Input board can only contain the characters ' ' and '*'."); - - new MinesweeperBoard(Collections.singletonList(" * & ")); - } - - @Ignore("Remove to run test") - @Test - public void testInputBoardWithInconsistentRowLengthsIsRejected() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Input board rows must all have the same number of columns."); - - new MinesweeperBoard(Arrays.asList( - "*", - "**", - "* *", - "* *", - "* *" - )); + assertEquals(expectedNumberedBoard, actualNumberedBoard); } }