11import org .junit .Ignore ;
2- import org .junit .Rule ;
32import org .junit .Test ;
4- import org .junit .rules .ExpectedException ;
53
64import java .util .Arrays ;
75import java .util .Collections ;
86import java .util .List ;
97
108import static org .junit .Assert .assertEquals ;
119
10+ /*
11+ * version: 1.0.0
12+ */
1213public class MinesweeperBoardTest {
1314
14- /*
15- * See https://github.com/junit-team/junit4/wiki/Rules for information on JUnit Rules in general and
16- * ExpectedExceptions in particular.
17- */
18- @ Rule
19- public ExpectedException expectedException = ExpectedException .none ();
20-
2115 @ Test
2216 public void testInputBoardWithNoRowsAndNoColumns () {
2317 final List <String > inputBoard = Collections .emptyList ();
24- final List <String > expectedAnnotatedRepresentation = Collections .emptyList ();
25- final List <String > actualAnnotatedRepresentation
26- = new MinesweeperBoard (inputBoard ).getAnnotatedRepresentation ();
18+ final List <String > expectedNumberedBoard = Collections .emptyList ();
19+ final List <String > actualNumberedBoard = new MinesweeperBoard (inputBoard ).withNumbers ();
2720
28- assertEquals (expectedAnnotatedRepresentation , actualAnnotatedRepresentation );
21+ assertEquals (expectedNumberedBoard , actualNumberedBoard );
2922 }
3023
3124 @ Ignore ("Remove to run test" )
3225 @ Test
3326 public void testInputBoardWithOneRowAndNoColumns () {
3427 final List <String > inputBoard = Collections .singletonList ("" );
35- final List <String > expectedAnnotatedRepresentation = Collections .singletonList ("" );
36- final List <String > actualAnnotatedRepresentation
37- = new MinesweeperBoard (inputBoard ).getAnnotatedRepresentation ();
28+ final List <String > expectedNumberedBoard = Collections .singletonList ("" );
29+ final List <String > actualNumberedBoard = new MinesweeperBoard (inputBoard ).withNumbers ();
3830
39- assertEquals (expectedAnnotatedRepresentation , actualAnnotatedRepresentation );
31+ assertEquals (expectedNumberedBoard , actualNumberedBoard );
4032 }
4133
4234 @ Ignore ("Remove to run test" )
@@ -48,16 +40,15 @@ public void testInputBoardWithNoMines() {
4840 " "
4941 );
5042
51- final List <String > expectedAnnotatedRepresentation = Arrays .asList (
43+ final List <String > expectedNumberedBoard = Arrays .asList (
5244 " " ,
5345 " " ,
5446 " "
5547 );
5648
57- final List <String > actualAnnotatedRepresentation
58- = new MinesweeperBoard (inputBoard ).getAnnotatedRepresentation ();
49+ final List <String > actualNumberedBoard = new MinesweeperBoard (inputBoard ).withNumbers ();
5950
60- assertEquals (expectedAnnotatedRepresentation , actualAnnotatedRepresentation );
51+ assertEquals (expectedNumberedBoard , actualNumberedBoard );
6152 }
6253
6354 @ Ignore ("Remove to run test" )
@@ -69,16 +60,15 @@ public void testInputBoardWithOnlyMines() {
6960 "***"
7061 );
7162
72- final List <String > expectedAnnotatedRepresentation = Arrays .asList (
63+ final List <String > expectedNumberedBoard = Arrays .asList (
7364 "***" ,
7465 "***" ,
7566 "***"
7667 );
7768
78- final List <String > actualAnnotatedRepresentation
79- = new MinesweeperBoard (inputBoard ).getAnnotatedRepresentation ();
69+ final List <String > actualNumberedBoard = new MinesweeperBoard (inputBoard ).withNumbers ();
8070
81- assertEquals (expectedAnnotatedRepresentation , actualAnnotatedRepresentation );
71+ assertEquals (expectedNumberedBoard , actualNumberedBoard );
8272 }
8373
8474 @ Ignore ("Remove to run test" )
@@ -90,16 +80,15 @@ public void testInputBoardWithSingleMineAtCenter() {
9080 " "
9181 );
9282
93- final List <String > expectedAnnotatedRepresentation = Arrays .asList (
83+ final List <String > expectedNumberedBoard = Arrays .asList (
9484 "111" ,
9585 "1*1" ,
9686 "111"
9787 );
9888
99- final List <String > actualAnnotatedRepresentation
100- = new MinesweeperBoard (inputBoard ).getAnnotatedRepresentation ();
89+ final List <String > actualNumberedBoard = new MinesweeperBoard (inputBoard ).withNumbers ();
10190
102- assertEquals (expectedAnnotatedRepresentation , actualAnnotatedRepresentation );
91+ assertEquals (expectedNumberedBoard , actualNumberedBoard );
10392 }
10493
10594 @ Ignore ("Remove to run test" )
@@ -111,16 +100,15 @@ public void testInputBoardWithMinesAroundPerimeter() {
111100 "***"
112101 );
113102
114- final List <String > expectedAnnotatedRepresentation = Arrays .asList (
103+ final List <String > expectedNumberedBoard = Arrays .asList (
115104 "***" ,
116105 "*8*" ,
117106 "***"
118107 );
119108
120- final List <String > actualAnnotatedRepresentation
121- = new MinesweeperBoard (inputBoard ).getAnnotatedRepresentation ();
109+ final List <String > actualNumberedBoard = new MinesweeperBoard (inputBoard ).withNumbers ();
122110
123- assertEquals (expectedAnnotatedRepresentation , actualAnnotatedRepresentation );
111+ assertEquals (expectedNumberedBoard , actualNumberedBoard );
124112 }
125113
126114 @ Ignore ("Remove to run test" )
@@ -130,14 +118,13 @@ public void testInputBoardWithSingleRowAndTwoMines() {
130118 " * * "
131119 );
132120
133- final List <String > expectedAnnotatedRepresentation = Collections .singletonList (
121+ final List <String > expectedNumberedBoard = Collections .singletonList (
134122 "1*2*1"
135123 );
136124
137- final List <String > actualAnnotatedRepresentation
138- = new MinesweeperBoard (inputBoard ).getAnnotatedRepresentation ();
125+ final List <String > actualNumberedBoard = new MinesweeperBoard (inputBoard ).withNumbers ();
139126
140- assertEquals (expectedAnnotatedRepresentation , actualAnnotatedRepresentation );
127+ assertEquals (expectedNumberedBoard , actualNumberedBoard );
141128 }
142129
143130 @ Ignore ("Remove to run test" )
@@ -147,14 +134,13 @@ public void testInputBoardWithSingleRowAndTwoMinesAtEdges() {
147134 "* *"
148135 );
149136
150- final List <String > expectedAnnotatedRepresentation = Collections .singletonList (
137+ final List <String > expectedNumberedBoard = Collections .singletonList (
151138 "*1 1*"
152139 );
153140
154- final List <String > actualAnnotatedRepresentation
155- = new MinesweeperBoard (inputBoard ).getAnnotatedRepresentation ();
141+ final List <String > actualNumberedBoard = new MinesweeperBoard (inputBoard ).withNumbers ();
156142
157- assertEquals (expectedAnnotatedRepresentation , actualAnnotatedRepresentation );
143+ assertEquals (expectedNumberedBoard , actualNumberedBoard );
158144 }
159145
160146 @ Ignore ("Remove to run test" )
@@ -168,18 +154,17 @@ public void testInputBoardWithSingleColumnAndTwoMines() {
168154 " "
169155 );
170156
171- final List <String > expectedAnnotatedRepresentation = Arrays .asList (
157+ final List <String > expectedNumberedBoard = Arrays .asList (
172158 "1" ,
173159 "*" ,
174160 "2" ,
175161 "*" ,
176162 "1"
177163 );
178164
179- final List <String > actualAnnotatedRepresentation
180- = new MinesweeperBoard (inputBoard ).getAnnotatedRepresentation ();
165+ final List <String > actualNumberedBoard = new MinesweeperBoard (inputBoard ).withNumbers ();
181166
182- assertEquals (expectedAnnotatedRepresentation , actualAnnotatedRepresentation );
167+ assertEquals (expectedNumberedBoard , actualNumberedBoard );
183168 }
184169
185170 @ Ignore ("Remove to run test" )
@@ -193,18 +178,17 @@ public void testInputBoardWithSingleColumnAndTwoMinesAtEdges() {
193178 "*"
194179 );
195180
196- final List <String > expectedAnnotatedRepresentation = Arrays .asList (
181+ final List <String > expectedNumberedBoard = Arrays .asList (
197182 "*" ,
198183 "1" ,
199184 " " ,
200185 "1" ,
201186 "*"
202187 );
203188
204- final List <String > actualAnnotatedRepresentation
205- = new MinesweeperBoard (inputBoard ).getAnnotatedRepresentation ();
189+ final List <String > actualNumberedBoard = new MinesweeperBoard (inputBoard ).withNumbers ();
206190
207- assertEquals (expectedAnnotatedRepresentation , actualAnnotatedRepresentation );
191+ assertEquals (expectedNumberedBoard , actualNumberedBoard );
208192 }
209193
210194 @ Ignore ("Remove to run test" )
@@ -218,18 +202,17 @@ public void testInputBoardWithMinesInCross() {
218202 " * "
219203 );
220204
221- final List <String > expectedAnnotatedRepresentation = Arrays .asList (
205+ final List <String > expectedNumberedBoard = Arrays .asList (
222206 " 2*2 " ,
223207 "25*52" ,
224208 "*****" ,
225209 "25*52" ,
226210 " 2*2 "
227211 );
228212
229- final List <String > actualAnnotatedRepresentation
230- = new MinesweeperBoard (inputBoard ).getAnnotatedRepresentation ();
213+ final List <String > actualNumberedBoard = new MinesweeperBoard (inputBoard ).withNumbers ();
231214
232- assertEquals (expectedAnnotatedRepresentation , actualAnnotatedRepresentation );
215+ assertEquals (expectedNumberedBoard , actualNumberedBoard );
233216 }
234217
235218 @ Ignore ("Remove to run test" )
@@ -244,7 +227,7 @@ public void testLargeInputBoard() {
244227 " "
245228 );
246229
247- final List <String > expectedAnnotatedRepresentation = Arrays .asList (
230+ final List <String > expectedNumberedBoard = Arrays .asList (
248231 "1*22*1" ,
249232 "12*322" ,
250233 " 123*2" ,
@@ -253,43 +236,9 @@ public void testLargeInputBoard() {
253236 "111111"
254237 );
255238
256- final List <String > actualAnnotatedRepresentation
257- = new MinesweeperBoard (inputBoard ).getAnnotatedRepresentation ();
258-
259- assertEquals (expectedAnnotatedRepresentation , actualAnnotatedRepresentation );
260- }
261-
262- @ Ignore ("Remove to run test" )
263- @ Test
264- public void testNullInputBoardIsRejected () {
265- expectedException .expect (IllegalArgumentException .class );
266- expectedException .expectMessage ("Input board may not be null." );
267-
268- new MinesweeperBoard (null );
269- }
239+ final List <String > actualNumberedBoard = new MinesweeperBoard (inputBoard ).withNumbers ();
270240
271- @ Ignore ("Remove to run test" )
272- @ Test
273- public void testInputBoardWithInvalidSymbolsIsRejected () {
274- expectedException .expect (IllegalArgumentException .class );
275- expectedException .expectMessage ("Input board can only contain the characters ' ' and '*'." );
276-
277- new MinesweeperBoard (Collections .singletonList (" * & " ));
278- }
279-
280- @ Ignore ("Remove to run test" )
281- @ Test
282- public void testInputBoardWithInconsistentRowLengthsIsRejected () {
283- expectedException .expect (IllegalArgumentException .class );
284- expectedException .expectMessage ("Input board rows must all have the same number of columns." );
285-
286- new MinesweeperBoard (Arrays .asList (
287- "*" ,
288- "**" ,
289- "* *" ,
290- "* *" ,
291- "* *"
292- ));
241+ assertEquals (expectedNumberedBoard , actualNumberedBoard );
293242 }
294243
295244}
0 commit comments