1 | package jpacman.model; |
2 | |
3 | import static org.junit.Assert.assertEquals; |
4 | |
5 | import org.junit.Before; |
6 | import org.junit.Test; |
7 | |
8 | /** |
9 | * Test suite for methods working directly on Cells. |
10 | * |
11 | * @author Arie van Deursen; Jul 29, 2003 |
12 | * @version $Id: CellTest.java,v 1.16 2008/02/10 12:51:55 arie Exp $ |
13 | */ |
14 | public class CellTest { |
15 | |
16 | /** |
17 | * Width & heigth of board to be used. |
18 | */ |
19 | private final int width = 4, height = 5; |
20 | |
21 | /** |
22 | * The board the cells occur on. |
23 | */ |
24 | private Board aBoard; |
25 | |
26 | /** |
27 | * The "Cell Under Test". |
28 | */ |
29 | private Cell aCell; |
30 | |
31 | /** |
32 | * Actually create the board and the cell. * |
33 | */ |
34 | @Before |
35 | public void setUpBoard() { |
36 | aBoard = new Board(width, height); |
37 | // put the cell on an invariant boundary value. |
38 | aCell = new Cell(0, height - 1, aBoard); |
39 | } |
40 | |
41 | |
42 | |
43 | /** |
44 | * Test obtaining a cell at a given offset. Ensure both postconditions |
45 | * (null value if beyond border, value with board) are executed. |
46 | */ |
47 | @Test |
48 | public void testCellAtOffset() { |
49 | assertEquals(height - 2, aCell.cellAtOffset(0, -1).getY()); |
50 | assertEquals(0, aCell.cellAtOffset(0, -1).getX()); |
51 | // assertNull(aCell.cellAtOffset(-1, 0)); |
52 | |
53 | Cell cell11 = aBoard.getCell(1, 1); |
54 | Cell cell12 = aBoard.getCell(1, 2); |
55 | assertEquals(cell12, cell11.cellAtOffset(0, 1)); |
56 | } |
57 | |
58 | } |