1 | package jpacman.model; |
2 | |
3 | import static org.junit.Assert.assertEquals; |
4 | import static org.junit.Assert.assertFalse; |
5 | import static org.junit.Assert.assertTrue; |
6 | |
7 | import org.junit.Test; |
8 | |
9 | /** |
10 | * Specialize the general MoveTest test suite to one |
11 | * that is tailored to PlayerMoves. |
12 | * Thanks to inheritance, all test cases from MoveTest |
13 | * are also methods in PlayerMoveTest, thus helping us |
14 | * to test conformance with Liskov's Substitution Principle (LSP) |
15 | * of the Move hierarchy. |
16 | * <p> |
17 | * @author Arie van Deursen; August 21, 2003. |
18 | * @version $Id: PlayerMoveTest.java,v 1.8 2008/02/10 19:51:11 arie Exp $ |
19 | */ |
20 | public class PlayerMoveTest extends MoveTest { |
21 | |
22 | /** |
23 | * The move the player would like to make. |
24 | */ |
25 | private PlayerMove aPlayerMove; |
26 | |
27 | /** |
28 | * Simple test of a few getters. |
29 | */ |
30 | @Test |
31 | public void testSimpleGetters() { |
32 | PlayerMove playerMove = new PlayerMove(thePlayer, foodCell); |
33 | assertEquals(thePlayer, playerMove.getPlayer()); |
34 | assertTrue(playerMove.movePossible()); |
35 | assertFalse(playerMove.playerDies()); |
36 | assertEquals(1, playerMove.getFoodEaten()); |
37 | assertTrue(playerMove.invariant()); |
38 | } |
39 | |
40 | |
41 | /** |
42 | * Create a move object that will be tested. |
43 | * @see jpacman.model.MoveTest#createMove(jpacman.model.Cell) |
44 | * @param target The cell to be occupied by the move. |
45 | * @return The move to be tested. |
46 | */ |
47 | @Override |
48 | protected PlayerMove createMove(Cell target) { |
49 | aPlayerMove = new PlayerMove(thePlayer, target); |
50 | return aPlayerMove; |
51 | } |
52 | } |