EMMA Coverage Report (generated Fri Mar 15 09:08:15 CET 2013)
[all classes][jpacman.model]

COVERAGE SUMMARY FOR SOURCE FILE [MoveTest.java]

nameclass, %method, %block, %line, %
MoveTest.java100% (1/1)100% (2/2)100% (60/60)100% (18/18)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class MoveTest100% (1/1)100% (2/2)100% (60/60)100% (18/18)
MoveTest (): void 100% (1/1)100% (3/3)100% (1/1)
testApply (): void 100% (1/1)100% (57/57)100% (17/17)

1package jpacman.model;
2 
3import static org.junit.Assert.assertEquals;
4import static org.junit.Assert.assertFalse;
5import static org.junit.Assert.assertNotNull;
6import static org.junit.Assert.assertTrue;
7 
8import org.junit.Test;
9 
10/**
11 * This class offers a test suite for the Move class hierarchy
12 * from Pacman. It contains test cases that should pass for
13 * <em>all</em> subclasses of Move, and builds a parallel class
14 * hierarchy for testing purposes.
15 *
16 * (For those familiar with Binder: this class follows the
17 * <em>Polymorphic Server Test</em> design pattern).
18 *
19 * @author Arie van Deursen; Aug 2, 2003
20 * @version $Id: MoveTest.java,v 1.6 2008/02/04 10:26:57 arie Exp $
21 */
22public abstract class MoveTest extends GameTestCase {
23 
24    /**
25     * The move we make.
26     */
27    private Move aMove;
28 
29    /**
30     * A simple test case that should hold for all moves:
31     * If the move is possible, the guest should indeed
32     * have been moved.
33     * Note that the creation of the Move object itself
34     * is deferred to subclasses via the createMove factory method.
35     */
36    @Test public void testApply() {
37        // create move, mover, and cell to be moved to.
38        aMove = createMove(emptyCell);
39        MovingGuest mover = aMove.getMovingGuest();
40        Cell location1 = mover.getLocation();
41        assertNotNull(mover);
42        assertNotNull(location1);
43 
44        // status before.
45        assertTrue(aMove.movePossible());
46        assertEquals(location1, mover.getLocation());
47        assertEquals(mover, location1.getInhabitant());
48 
49        // do the move.
50        aMove.apply();
51        Cell location2 = mover.getLocation();
52        assertNotNull(location2);
53        assertFalse(location1.isOccupied());
54        assertEquals(emptyCell, location2);
55        assertEquals(mover, location2.getInhabitant());
56        assertTrue(aMove.moveDone());
57        assertFalse(aMove.movePossible());
58 
59    }
60 
61 
62    /**
63     * Create a move object.
64     * The actual guest to be moved (to the target Cell)
65     * is determined in the subclasses, who also know how to create
66     * the specific Move subclass for that type of guest.
67     * (See the Gang-of-Four (Gamma et al) "Factory Method" design pattern)
68     * @param target Cell to be moved to
69     * @return Instantiated Move subclass object.
70     */
71    protected abstract Move createMove(Cell target);
72}

[all classes][jpacman.model]
EMMA 2.0.5312 (C) Vladimir Roubtsov