Repository navigation
Expand file tree
/
Copy pathChessGameTester.java
More file actions
521 lines (496 loc) · 31 KB
/
Copy pathChessGameTester.java
File metadata and controls
521 lines (496 loc) · 31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* A class which tests method from the ChessGame Hierarchy implemented in the following classes:
* 1.) EuropeanChess
* 2.) Xiangqi
* @author Peter Schlueter
*
*/
public class ChessGameTester
{
//ChessGame gameRules stores the rules of a game of Chess (preset to EuropeanChess)
private ChessGame gameRules = new EuropeanChess();
//SwingChessBoardDisplay swingDisplay stores a display of the ChessBoard done in Swing
private SwingChessBoardDisplay swingDisplay = new SwingEuropeanChessDisplay();
//SwingChessBoard swingBoard stores a chess board implemnted in Swing
private SwingChessBoard swingBoard = new SwingChessBoard(swingDisplay, gameRules);
//JavaFXChessBoard fxBoard stores a chess board implemented in JavaFX for EuropeanChess
private JavaFXChessBoard fxBoard = new JavaFXChessBoard();
/**
* Tests legalPieceToPlay(ChessPiece piece, int row, int column) from EuropeanChess class
* Note that, by default, the starting player is always the one of the north side
*/
@Test
public void testLegalPieceToPlayEuroChess()
{
//PawnPiece testLegalToPlay stores a PawnPiece used to test this method (north side trying to use north side piece)
PawnPiece testLegalToPlay = new PawnPiece(ChessGame.Side.NORTH, 4, 4, swingBoard);
//PawnPiece testPieceIllegalToPlay stores a PawnPiece used to test this method (north side trying to use south side piece)
PawnPiece testIllegalToPlay = new PawnPiece(ChessGame.Side.SOUTH, 4, 4, swingBoard);
//Tests if the player on the north side is trying to use a piece of the north side that this is a legal piece to play
assertTrue(gameRules.legalPieceToPlay(testLegalToPlay, 4, 4));
//Tests if the player on the north side is trying to use a piece of the south side that this is not a legal piece to play
assertFalse(gameRules.legalPieceToPlay(testIllegalToPlay, 4, 4));
}
/**
* Tests legalPieceToPlay(ChessPiece piece, int row, int column) from EuropeanChess class
* Again, it is worth noting that, by default, the starting player is always the one on the north side
*/
@Test
public void testMakeMoveEuroChess()
{
//QueenPiece testNorthPiece stores a QueenPiece used to test condtions where the piece can move this turn
QueenPiece testNorthPiece = new QueenPiece(ChessGame.Side.NORTH, 4, 4, swingBoard);
swingBoard.addPiece(testNorthPiece, 4, 4);
//PawnPiece testSouthPiece stores a PawnPiece used to test conditions where this piece will not move this turn
PawnPiece testSouthPiece = new PawnPiece(ChessGame.Side.SOUTH, 4, 4, swingBoard);
//PawnPiece testCapture storse a PawnPiece used to test conditions where the move being made is a legal capture move
PawnPiece testCapture = new PawnPiece(ChessGame.Side.NORTH, 3, 0, swingBoard);
swingBoard.addPiece(testCapture, 3, 0);
//Tests If the player on the north side is trying to use a piece of the north side,
//the piece is making a legal non capture move or legal capture move (legal non-capture move in this test),
//and the player is of the north side, then the move is made and the player side is swapped to south
assertTrue(gameRules.makeMove(testNorthPiece, 4, 5));
assertTrue(!(testNorthPiece.getToBeUpgraded()));
swingBoard.addPiece(testSouthPiece, 4, 1);
//This test shows the player side has been set back to the south side (a player on the south side cannot play a piece of the north side)
assertFalse(gameRules.legalPieceToPlay(testNorthPiece, 3, 0));
//Tests If the player on the south side is trying to use a piece of the south side,
//the piece is making a legal non capture move or legal capture move (legal capture move in this test),
//the piece should be upgraded this turn, and the player is on the south side
//then the move is made, the pawn is upgraded and set to not be upgraded next turn, and the player is swapped to north
assertTrue(gameRules.makeMove(testSouthPiece, 3, 0));
assertTrue(testSouthPiece.getToBeUpgraded() == false);
//This test shows the player side has been set back to the north side (a player on the north side cannot play a piece of the south side)
assertFalse(gameRules.legalPieceToPlay(testSouthPiece, 3, 0));
//Tests that this piece cannot be moved if it is not of the same side as the person currently trying to move it
assertFalse(gameRules.makeMove(testSouthPiece, 3, 0));
//Tests that this piece cannot be moved if the input location is not representative of a legal capture move or legal non capture move
assertFalse(gameRules.makeMove(testNorthPiece, 0, 3));
}
/**
* Tests getNumRows() from EuropeanChess
*/
@Test
public void testGetNumRowsEuroChess()
{
//Should return the number of rows in a EuropeanChess instance (which is 8 rows)
assertEquals(8, gameRules.getNumRows());
}
/**
* Tests getNumColumns from EuropeanChess
*/
@Test
public void testGetNumColumnsEuroChess()
{
//Should return the number of columsn in a EuropeanChess instance (which is 8 columns)
assertEquals(8, gameRules.getNumColumns());
}
/**
* Tests legalPieceToPlay from Xiangqi
* Note that by default, the player that starts the game (i.e. has the first turn) will always be the player of the NORTH side
*/
@Test
public void testLegalPieceToPlayXiangqi()
{
//HorsePiece testLegalToPlay stores a HorsePiece used to test this method (north side trying to use north side piece)
HorsePiece testLegalToPlay = new HorsePiece(ChessGame.Side.NORTH, 4, 4, swingBoard);
//HorsePiece testPieceIllegalToPlay stores a HorsePiece used to test this method (north side trying to use south side piece)
HorsePiece testIllegalToPlay = new HorsePiece(ChessGame.Side.SOUTH, 4, 4, swingBoard);
//Tests if the player on the north side is trying to use a piece of the north side that this is a legal piece to play
assertTrue(gameRules.legalPieceToPlay(testLegalToPlay, 4, 4));
//Tests if the player on the north side is trying to use a piece of the south side that this is not a legal piece to play
assertFalse(gameRules.legalPieceToPlay(testIllegalToPlay, 4, 4));
}
/**
* Tests makeMove from Xiangqi and private method areNoPiecesBetweenKings(ChessPiece piece) from Xiangqi
* Note that by default, the player that starts the game (i.e. has the first turn) will always be the player of the NORTH side
*/
@Test
public void testMakeMoveXiangqi()
{
gameRules = new Xiangqi();
swingBoard = new SwingChessBoard(swingDisplay, gameRules);
//XiangqiKingPiece testFacingKingsNorth stores a XiangqiKingPiece used to test that moves which create "facing kings" situations are prevented
XiangqiKingPiece testFacingKingsNorth = new XiangqiKingPiece(ChessGame.Side.NORTH, 1, 4, swingBoard);
swingBoard.addPiece(testFacingKingsNorth, 1, 4);
//XiangqiKingPiece testFacingKingsSouth stores a XiangqiKingPiece used to test that moves which create "facing kings" situations are prevented
XiangqiKingPiece testFacingKingsSouth = new XiangqiKingPiece(ChessGame.Side.SOUTH, 8, 4, swingBoard);
swingBoard.addPiece(testFacingKingsSouth, 8, 4);
//SoldierPiece betweenKings stores a SoldierPiece used to test that moves which create "facing kings" situations are prevented
SoldierPiece betweenKings = new SoldierPiece(ChessGame.Side.NORTH, 4, 4, swingBoard);
swingBoard.addPiece(betweenKings, 4, 4);
//SoldierPiece testNorthPiece stores a SoldierKingPiece used to test condtions where a non-king piece can move this turn
SoldierPiece testNorthPiece = new SoldierPiece(ChessGame.Side.NORTH, 3, 2, swingBoard);
swingBoard.addPiece(testNorthPiece, 3, 2);
//HorsePiece testSouthPiece stores a HorsePiece used to test conditions where this piece will not move this turn (does not include facing kings scenarios)
HorsePiece testSouthPiece = new HorsePiece(ChessGame.Side.SOUTH, 3, 1, swingBoard);
swingBoard.addPiece(testSouthPiece, 3, 1);
//ElephantPiece testCapture storse an ElephantPiece used to test conditions where the move being made is a legal capture move
ElephantPiece testCapture = new ElephantPiece(ChessGame.Side.NORTH, 5, 3, swingBoard);
swingBoard.addPiece(testCapture, 5, 2);
//Tests If the player on the north side is trying to use a piece of the north side,
//the piece is making a legal non capture move or legal capture move (legal non-capture move in this test),
//and the player is of the north side, then the move is made and the player side is swapped to south
assertTrue(gameRules.makeMove(testNorthPiece, 4, 2));
//This test shows the player side has been set back to the south side (a player on the south side cannot play a piece of the north side)
assertFalse(gameRules.legalPieceToPlay(testNorthPiece, 4, 2));
//Tests If the player on the south side is trying to use a piece of the south side,
//the piece is making a legal non capture move or legal capture move (legal capture move in this test),
//the piece should be upgraded this turn, and the player is on the south side
//then the move is made and the player is swapped to north
assertTrue(gameRules.makeMove(testSouthPiece, 5, 2));
//This test shows the player side has been set back to the north side (a player on the north side cannot play a piece of the south side)
assertFalse(gameRules.legalPieceToPlay(testSouthPiece, 5, 2));
//Tests that this piece cannot be moved if it is not of the same side as the person currently trying to move it
assertFalse(gameRules.makeMove(testSouthPiece, 7, 3));
//Tests that this piece cannot be moved if the input location is not representative of a legal capture move or legal non capture move
assertFalse(gameRules.makeMove(testNorthPiece, 6, 7));
/* The following section contains tests for moves which create "facing kings" situations */
//This segment also tests the private method areNoPiecesBetweenKings(ChessPiece piece) from Xiangqi
//The following moves should be allowed as they do not create facing kings situations
assertTrue(gameRules.makeMove(betweenKings, 5, 4)); //Should allow this piece to move up one space since the kings cannot "see" each other
assertTrue(gameRules.makeMove(testFacingKingsSouth, 7, 4)); //Should allow this piece to move forward one space since the kings cannot "see" each other
assertTrue(gameRules.makeMove(testFacingKingsNorth, 0, 4)); //Should allow this piece to move back one space since the kings cannot "see" each other
assertTrue(gameRules.makeMove(testFacingKingsSouth, 7, 3)); //Should allow this piece to move left one because the kings are not on the same column
assertTrue(gameRules.makeMove(betweenKings, 5, 3)); //Should allow this piece to move left one space because the kings are not on the same column
//The following moves, unless otherwise specified, should not be allowed as the create a facing kings situation
assertFalse(gameRules.makeMove(testFacingKingsSouth, 7, 4)); //Should not be allowed to move right one space because the two kings can "see" each other (on same column with no pieces between them)
gameRules.makeMove(betweenKings, 5, 4); //Resets position of betweenKings for following tests
assertFalse(gameRules.makeMove(testFacingKingsNorth, 0, 3)); //Should not be allowed to move left one space because the two kings can "see" each other (on same column with no pieces between them)
gameRules.makeMove(testFacingKingsSouth, 8, 3); //Moves piece of SOUTH side so a piece on the NORTH side can be moved for the next test
assertFalse(gameRules.makeMove(betweenKings, 5, 5)); //Should not be allowed to move right one space because the two kings can "see" each other (on same column with no pieces between them)
}
/**
* Tests getNumRows() from Xiangqi
*/
@Test
public void testGetNumRowsXiangqi()
{
gameRules = new Xiangqi();
//Should return the number of rows on a board in a game of Xiangqi (which is 10)
assertEquals(10, gameRules.getNumRows());
}
/**
* Tests getNumColumns() from Xiangqi
*/
@Test
public void testGetNumColumnsXiangqi()
{
gameRules = new Xiangqi();
//Should return the number of columns on a board in a game of Xiangqi (which is 9)
assertEquals(9, gameRules.getNumColumns());
}
/**
* Tests startGame(ChessBoard board) from EuropeanChess
*/
@Test
public void testStartGameEuroChess()
{
//Calling startGame should set the pieces to the correct initial locations
gameRules.startGame(swingBoard);
/*
* Each test below checks that each of the following are true for pieces of the NORTH side
* 1.) These pieces are all of the correct type
* 2.) These pieces are all of the NORTH side
* 3.) These pieces are assigned to the correct row
* 4.) These pieces are assigned to the correct column
* 5.) These pieces are all on the correct chess board
*/
assertTrue(swingBoard.getPiece(0, 0) instanceof RookPiece);
assertTrue(swingBoard.getPiece(0, 0).getSide() == ChessGame.Side.NORTH);
assertTrue(swingBoard.getPiece(0, 0).getRow() == 0);
assertTrue(swingBoard.getPiece(0, 0).getColumn() == 0);
assertTrue(swingBoard.getPiece(0, 0).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(0, 1) instanceof KnightPiece);
assertTrue(swingBoard.getPiece(0, 1).getSide() == ChessGame.Side.NORTH);
assertTrue(swingBoard.getPiece(0, 1).getRow() == 0);
assertTrue(swingBoard.getPiece(0, 1).getColumn() == 1);
assertTrue(swingBoard.getPiece(0, 1).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(0, 2) instanceof BishopPiece);
assertTrue(swingBoard.getPiece(0, 2).getSide() == ChessGame.Side.NORTH);
assertTrue(swingBoard.getPiece(0, 2).getRow() == 0);
assertTrue(swingBoard.getPiece(0, 2).getColumn() == 2);
assertTrue(swingBoard.getPiece(0, 2).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(0, 3) instanceof QueenPiece);
assertTrue(swingBoard.getPiece(0, 3).getSide() == ChessGame.Side.NORTH);
assertTrue(swingBoard.getPiece(0, 3).getRow() == 0);
assertTrue(swingBoard.getPiece(0, 3).getColumn() == 3);
assertTrue(swingBoard.getPiece(0, 3).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(0, 4) instanceof KingPiece);
assertTrue(swingBoard.getPiece(0, 4).getSide() == ChessGame.Side.NORTH);
assertTrue(swingBoard.getPiece(0, 4).getRow() == 0);
assertTrue(swingBoard.getPiece(0, 4).getColumn() == 4);
assertTrue(swingBoard.getPiece(0, 4).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(0, 5) instanceof BishopPiece);
assertTrue(swingBoard.getPiece(0, 5).getSide() == ChessGame.Side.NORTH);
assertTrue(swingBoard.getPiece(0, 5).getRow() == 0);
assertTrue(swingBoard.getPiece(0, 5).getColumn() == 5);
assertTrue(swingBoard.getPiece(0, 5).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(0, 6) instanceof KnightPiece);
assertTrue(swingBoard.getPiece(0, 6).getSide() == ChessGame.Side.NORTH);
assertTrue(swingBoard.getPiece(0, 6).getRow() == 0);
assertTrue(swingBoard.getPiece(0, 6).getColumn() == 6);
assertTrue(swingBoard.getPiece(0, 6).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(0, 7) instanceof RookPiece);
assertTrue(swingBoard.getPiece(0, 7).getSide() == ChessGame.Side.NORTH);
assertTrue(swingBoard.getPiece(0, 7).getRow() == 0);
assertTrue(swingBoard.getPiece(0, 7).getColumn() == 7);
assertTrue(swingBoard.getPiece(0, 7).getChessBoard() == swingBoard);
//Loop-Goal: Check all of the conditions for this section (described above) for pawn pieces
for (int c = 0; c < swingBoard.getGameRules().getNumRows(); c++)
{
assertTrue(swingBoard.getPiece(1, c) instanceof PawnPiece);
assertTrue(swingBoard.getPiece(1, c).getSide() == ChessGame.Side.NORTH);
assertTrue(swingBoard.getPiece(1, c).getRow() == 1);
assertTrue(swingBoard.getPiece(1, c).getColumn() == c);
assertTrue(swingBoard.getPiece(1, c).getChessBoard() == swingBoard);
}
/*
* Each test below checks that each of the following are true for pieces of the SOUTH side
* 1.) These pieces are all of the correct type
* 2.) These pieces are all of the SOUTH side
* 3.) These pieces are assigned to the correct row
* 4.) These pieces are assigned to the correct column
* 5.) These pieces are all on the correct chess board
*/
assertTrue(swingBoard.getPiece(7, 0) instanceof RookPiece);
assertTrue(swingBoard.getPiece(7, 0).getSide() == ChessGame.Side.SOUTH);
assertTrue(swingBoard.getPiece(7, 0).getRow() == 7);
assertTrue(swingBoard.getPiece(7, 0).getColumn() == 0);
assertTrue(swingBoard.getPiece(7, 0).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(7, 1) instanceof KnightPiece);
assertTrue(swingBoard.getPiece(7, 1).getSide() == ChessGame.Side.SOUTH);
assertTrue(swingBoard.getPiece(7, 1).getRow() == 7);
assertTrue(swingBoard.getPiece(7, 1).getColumn() == 1);
assertTrue(swingBoard.getPiece(7, 1).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(7, 2) instanceof BishopPiece);
assertTrue(swingBoard.getPiece(7, 2).getSide() == ChessGame.Side.SOUTH);
assertTrue(swingBoard.getPiece(7, 2).getRow() == 7);
assertTrue(swingBoard.getPiece(7, 2).getColumn() == 2);
assertTrue(swingBoard.getPiece(7, 2).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(7, 3) instanceof QueenPiece);
assertTrue(swingBoard.getPiece(7, 3).getSide() == ChessGame.Side.SOUTH);
assertTrue(swingBoard.getPiece(7, 3).getRow() == 7);
assertTrue(swingBoard.getPiece(7, 3).getColumn() == 3);
assertTrue(swingBoard.getPiece(7, 3).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(7, 4) instanceof KingPiece);
assertTrue(swingBoard.getPiece(7, 4).getSide() == ChessGame.Side.SOUTH);
assertTrue(swingBoard.getPiece(7, 4).getRow() == 7);
assertTrue(swingBoard.getPiece(7, 4).getColumn() == 4);
assertTrue(swingBoard.getPiece(7, 4).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(7, 5) instanceof BishopPiece);
assertTrue(swingBoard.getPiece(7, 5).getSide() == ChessGame.Side.SOUTH);
assertTrue(swingBoard.getPiece(7, 5).getRow() == 7);
assertTrue(swingBoard.getPiece(7, 5).getColumn() == 5);
assertTrue(swingBoard.getPiece(7, 5).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(7, 6) instanceof KnightPiece);
assertTrue(swingBoard.getPiece(7, 6).getSide() == ChessGame.Side.SOUTH);
assertTrue(swingBoard.getPiece(7, 6).getRow() == 7);
assertTrue(swingBoard.getPiece(7, 6).getColumn() == 6);
assertTrue(swingBoard.getPiece(7, 6).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(7, 7) instanceof RookPiece);
assertTrue(swingBoard.getPiece(7, 7).getSide() == ChessGame.Side.SOUTH);
assertTrue(swingBoard.getPiece(7, 7).getRow() == 7);
assertTrue(swingBoard.getPiece(7, 7).getColumn() == 7);
assertTrue(swingBoard.getPiece(7, 7).getChessBoard() == swingBoard);
//Loop-Goal: Check that each piece in this row is a pawn piece (SOUTH side)
for (int c = 0; c < swingBoard.getGameRules().getNumRows(); c++)
{
assertTrue(swingBoard.getPiece(6, c) instanceof PawnPiece);
assertTrue(swingBoard.getPiece(6, c).getSide() == ChessGame.Side.SOUTH);
assertTrue(swingBoard.getPiece(6, c).getRow() == 6);
assertTrue(swingBoard.getPiece(6, c).getColumn() == c);
assertTrue(swingBoard.getPiece(6, c).getChessBoard() == swingBoard);
}
}
/**
* Tests startGame(ChessBoard board) from Xiangqi
*/
@Test
public void testStartGameXiangqi()
{
gameRules = new Xiangqi();
ChessBoard swingBoard = new SwingChessBoard(swingDisplay, gameRules);
//Calling startGame should set the pieces to the correct initial locations
gameRules.startGame(swingBoard);
/*
* Each test below checks that each of the following are true for pieces of the NORTH side
* 1.) These pieces are all of the correct type
* 2.) These pieces are all of the NORTH side
* 3.) These pieces are assigned to the correct row
* 4.) These pieces are assigned to the correct column
* 5.) These pieces are all on the correct chess board
*/
assertTrue(swingBoard.getPiece(0, 0) instanceof RookPiece);
assertTrue(swingBoard.getPiece(0, 0).getSide() == ChessGame.Side.NORTH);
assertTrue(swingBoard.getPiece(0, 0).getRow() == 0);
assertTrue(swingBoard.getPiece(0, 0).getColumn() == 0);
assertTrue(swingBoard.getPiece(0, 0).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(0, 1) instanceof HorsePiece);
assertTrue(swingBoard.getPiece(0, 1).getSide() == ChessGame.Side.NORTH);
assertTrue(swingBoard.getPiece(0, 1).getRow() == 0);
assertTrue(swingBoard.getPiece(0, 1).getColumn() == 1);
assertTrue(swingBoard.getPiece(0, 1).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(0, 2) instanceof ElephantPiece);
assertTrue(swingBoard.getPiece(0, 2).getSide() == ChessGame.Side.NORTH);
assertTrue(swingBoard.getPiece(0, 2).getRow() == 0);
assertTrue(swingBoard.getPiece(0, 2).getColumn() == 2);
assertTrue(swingBoard.getPiece(0, 2).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(0, 3) instanceof GuardPiece);
assertTrue(swingBoard.getPiece(0, 3).getSide() == ChessGame.Side.NORTH);
assertTrue(swingBoard.getPiece(0, 3).getRow() == 0);
assertTrue(swingBoard.getPiece(0, 3).getColumn() == 3);
assertTrue(swingBoard.getPiece(0, 3).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(0, 4) instanceof XiangqiKingPiece);
assertTrue(swingBoard.getPiece(0, 4).getSide() == ChessGame.Side.NORTH);
assertTrue(swingBoard.getPiece(0, 4).getRow() == 0);
assertTrue(swingBoard.getPiece(0, 4).getColumn() == 4);
assertTrue(swingBoard.getPiece(0, 4).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(0, 5) instanceof GuardPiece);
assertTrue(swingBoard.getPiece(0, 5).getSide() == ChessGame.Side.NORTH);
assertTrue(swingBoard.getPiece(0, 5).getRow() == 0);
assertTrue(swingBoard.getPiece(0, 5).getColumn() == 5);
assertTrue(swingBoard.getPiece(0, 5).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(0, 6) instanceof ElephantPiece);
assertTrue(swingBoard.getPiece(0, 6).getSide() == ChessGame.Side.NORTH);
assertTrue(swingBoard.getPiece(0, 6).getRow() == 0);
assertTrue(swingBoard.getPiece(0, 6).getColumn() == 6);
assertTrue(swingBoard.getPiece(0, 6).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(0, 7) instanceof HorsePiece);
assertTrue(swingBoard.getPiece(0, 7).getSide() == ChessGame.Side.NORTH);
assertTrue(swingBoard.getPiece(0, 7).getRow() == 0);
assertTrue(swingBoard.getPiece(0, 7).getColumn() == 7);
assertTrue(swingBoard.getPiece(0, 7).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(0, 8) instanceof RookPiece);
assertTrue(swingBoard.getPiece(0, 8).getSide() == ChessGame.Side.NORTH);
assertTrue(swingBoard.getPiece(0, 8).getRow() == 0);
assertTrue(swingBoard.getPiece(0, 8).getColumn() == 8);
assertTrue(swingBoard.getPiece(0, 8).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(2, 1) instanceof CannonPiece);
assertTrue(swingBoard.getPiece(2, 1).getSide() == ChessGame.Side.NORTH);
assertTrue(swingBoard.getPiece(2, 1).getRow() == 2);
assertTrue(swingBoard.getPiece(2, 1).getColumn() == 1);
assertTrue(swingBoard.getPiece(2, 1).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(2, 7) instanceof CannonPiece);
assertTrue(swingBoard.getPiece(2, 7).getSide() == ChessGame.Side.NORTH);
assertTrue(swingBoard.getPiece(2, 7).getRow() == 2);
assertTrue(swingBoard.getPiece(2, 7).getColumn() == 7);
assertTrue(swingBoard.getPiece(2, 7).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(3, 0) instanceof SoldierPiece);
assertTrue(swingBoard.getPiece(3, 0).getSide() == ChessGame.Side.NORTH);
assertTrue(swingBoard.getPiece(3, 0).getRow() == 3);
assertTrue(swingBoard.getPiece(3, 0).getColumn() == 0);
assertTrue(swingBoard.getPiece(3, 0).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(3, 2) instanceof SoldierPiece);
assertTrue(swingBoard.getPiece(3, 2).getSide() == ChessGame.Side.NORTH);
assertTrue(swingBoard.getPiece(3, 2).getRow() == 3);
assertTrue(swingBoard.getPiece(3, 2).getColumn() == 2);
assertTrue(swingBoard.getPiece(3, 2).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(3, 4) instanceof SoldierPiece);
assertTrue(swingBoard.getPiece(3, 4).getSide() == ChessGame.Side.NORTH);
assertTrue(swingBoard.getPiece(3, 4).getRow() == 3);
assertTrue(swingBoard.getPiece(3, 4).getColumn() == 4);
assertTrue(swingBoard.getPiece(3, 4).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(3, 6) instanceof SoldierPiece);
assertTrue(swingBoard.getPiece(3, 6).getSide() == ChessGame.Side.NORTH);
assertTrue(swingBoard.getPiece(3, 6).getRow() == 3);
assertTrue(swingBoard.getPiece(3, 6).getColumn() == 6);
assertTrue(swingBoard.getPiece(3, 6).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(3, 8) instanceof SoldierPiece);
assertTrue(swingBoard.getPiece(3, 8).getSide() == ChessGame.Side.NORTH);
assertTrue(swingBoard.getPiece(3, 8).getRow() == 3);
assertTrue(swingBoard.getPiece(3, 8).getColumn() == 8);
assertTrue(swingBoard.getPiece(3, 8).getChessBoard() == swingBoard);
/*
* Each test below checks that each of the following are true for pieces of the SOUTH side
* 1.) These pieces are all of the correct type
* 2.) These pieces are all of the SOUTH side
* 3.) These pieces are assigned to the correct row
* 4.) These pieces are assigned to the correct column
* 5.) These pieces are all on the correct chess board
*/
assertTrue(swingBoard.getPiece(9, 0) instanceof RookPiece);
assertTrue(swingBoard.getPiece(9, 0).getSide() == ChessGame.Side.SOUTH);
assertTrue(swingBoard.getPiece(9, 0).getRow() == 9);
assertTrue(swingBoard.getPiece(9, 0).getColumn() == 0);
assertTrue(swingBoard.getPiece(9, 0).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(9, 1) instanceof HorsePiece);
assertTrue(swingBoard.getPiece(9, 1).getSide() == ChessGame.Side.SOUTH);
assertTrue(swingBoard.getPiece(9, 1).getRow() == 9);
assertTrue(swingBoard.getPiece(9, 1).getColumn() == 1);
assertTrue(swingBoard.getPiece(9, 1).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(9, 2) instanceof ElephantPiece);
assertTrue(swingBoard.getPiece(9, 2).getSide() == ChessGame.Side.SOUTH);
assertTrue(swingBoard.getPiece(9, 2).getRow() == 9);
assertTrue(swingBoard.getPiece(9, 2).getColumn() == 2);
assertTrue(swingBoard.getPiece(9, 2).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(9, 3) instanceof GuardPiece);
assertTrue(swingBoard.getPiece(9, 3).getSide() == ChessGame.Side.SOUTH);
assertTrue(swingBoard.getPiece(9, 3).getRow() == 9);
assertTrue(swingBoard.getPiece(9, 3).getColumn() == 3);
assertTrue(swingBoard.getPiece(9, 3).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(9, 4) instanceof XiangqiKingPiece);
assertTrue(swingBoard.getPiece(9, 4).getSide() == ChessGame.Side.SOUTH);
assertTrue(swingBoard.getPiece(9, 4).getRow() == 9);
assertTrue(swingBoard.getPiece(9, 4).getColumn() == 4);
assertTrue(swingBoard.getPiece(9, 4).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(9, 5) instanceof GuardPiece);
assertTrue(swingBoard.getPiece(9, 5).getSide() == ChessGame.Side.SOUTH);
assertTrue(swingBoard.getPiece(9, 5).getRow() == 9);
assertTrue(swingBoard.getPiece(9, 5).getColumn() == 5);
assertTrue(swingBoard.getPiece(9, 5).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(9, 6) instanceof ElephantPiece);
assertTrue(swingBoard.getPiece(9, 6).getSide() == ChessGame.Side.SOUTH);
assertTrue(swingBoard.getPiece(9, 6).getRow() == 9);
assertTrue(swingBoard.getPiece(9, 6).getColumn() == 6);
assertTrue(swingBoard.getPiece(9, 6).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(9, 7) instanceof HorsePiece);
assertTrue(swingBoard.getPiece(9, 7).getSide() == ChessGame.Side.SOUTH);
assertTrue(swingBoard.getPiece(9, 7).getRow() == 9);
assertTrue(swingBoard.getPiece(9, 7).getColumn() == 7);
assertTrue(swingBoard.getPiece(9, 7).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(9, 8) instanceof RookPiece);
assertTrue(swingBoard.getPiece(9, 8).getSide() == ChessGame.Side.SOUTH);
assertTrue(swingBoard.getPiece(9, 8).getRow() == 9);
assertTrue(swingBoard.getPiece(9, 8).getColumn() == 8);
assertTrue(swingBoard.getPiece(9, 8).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(7, 1) instanceof CannonPiece);
assertTrue(swingBoard.getPiece(7, 1).getSide() == ChessGame.Side.SOUTH);
assertTrue(swingBoard.getPiece(7, 1).getRow() == 7);
assertTrue(swingBoard.getPiece(7, 1).getColumn() == 1);
assertTrue(swingBoard.getPiece(7, 1).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(7, 7) instanceof CannonPiece);
assertTrue(swingBoard.getPiece(7, 7).getSide() == ChessGame.Side.SOUTH);
assertTrue(swingBoard.getPiece(7, 7).getRow() == 7);
assertTrue(swingBoard.getPiece(7, 7).getColumn() == 7);
assertTrue(swingBoard.getPiece(7, 7).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(6, 0) instanceof SoldierPiece);
assertTrue(swingBoard.getPiece(6, 0).getSide() == ChessGame.Side.SOUTH);
assertTrue(swingBoard.getPiece(6, 0).getRow() == 6);
assertTrue(swingBoard.getPiece(6, 0).getColumn() == 0);
assertTrue(swingBoard.getPiece(6, 0).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(6, 2) instanceof SoldierPiece);
assertTrue(swingBoard.getPiece(6, 2).getSide() == ChessGame.Side.SOUTH);
assertTrue(swingBoard.getPiece(6, 2).getRow() == 6);
assertTrue(swingBoard.getPiece(6, 2).getColumn() == 2);
assertTrue(swingBoard.getPiece(6, 2).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(6, 4) instanceof SoldierPiece);
assertTrue(swingBoard.getPiece(6, 4).getSide() == ChessGame.Side.SOUTH);
assertTrue(swingBoard.getPiece(6, 4).getRow() == 6);
assertTrue(swingBoard.getPiece(6, 4).getColumn() == 4);
assertTrue(swingBoard.getPiece(6, 4).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(6, 6) instanceof SoldierPiece);
assertTrue(swingBoard.getPiece(6, 6).getSide() == ChessGame.Side.SOUTH);
assertTrue(swingBoard.getPiece(6, 6).getRow() == 6);
assertTrue(swingBoard.getPiece(6, 6).getColumn() == 6);
assertTrue(swingBoard.getPiece(6, 6).getChessBoard() == swingBoard);
assertTrue(swingBoard.getPiece(6, 8) instanceof SoldierPiece);
assertTrue(swingBoard.getPiece(6, 8).getSide() == ChessGame.Side.SOUTH);
assertTrue(swingBoard.getPiece(6, 8).getRow() == 6);
assertTrue(swingBoard.getPiece(6, 8).getColumn() == 8);
assertTrue(swingBoard.getPiece(6, 8).getChessBoard() == swingBoard);
}
}