Skip to content

Commit 1943147

Browse files
committed
Engine Tests Converted
1 parent 565fd5c commit 1943147

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# branch-by-abstraction
22

3-
A demonstration of branching by abstration
3+
A demonstration of branching by abstration. Each of the headings below corresponds to a commit message, allowing you to follow the progress of the branch.
44

55
## Initial State
66

@@ -16,4 +16,8 @@ Next I implement the interface, without changing the classes which access the bo
1616

1717
## Partially Transition
1818

19-
I have partially transitions to using the new interface, in the tests for LifeBoard. The tests for Engine still use the old interface, but everything compiles and I can push to master without causing a riot.
19+
I have partially transitions to using the new interface, in the tests for LifeBoard. The tests for Engine still use the old interface, but everything compiles and I can push to master without causing a riot.
20+
21+
## Engine Tests Converted
22+
23+
The engine tests have been converted. Notice that they still take advantage of the fact that the board implementation is static. This is because the engine itself hasn't been converted.

src/test/java/EngineTest.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,14 @@ public class EngineTest {
1313
static final int Y_POINT = 10;
1414

1515
private Engine engine;
16+
private LifeBoard board;
1617

1718
@Before
1819
public void setUp() {
1920
engine = new Engine();
21+
board = new LifeBoard();
2022

21-
for(int x = 0; x < LifeBoard.X_MAX; ++x) {
22-
for(int y = 0; y < LifeBoard.Y_MAX; ++y) {
23-
LifeBoard.value[x][y] = false;
24-
}
25-
}
26-
23+
board.clear();
2724
}
2825

2926
@Test
@@ -33,7 +30,7 @@ public void neighbors_givenEmptyBoard_returnsZero() {
3330

3431
@Test
3532
public void neighbors_givenOneNeighbor_returnsOne() {
36-
LifeBoard.value[9][9] = true;
33+
board.set(9,9, 1);
3734
assertThat(engine.neighbors(X_POINT, Y_POINT), is(1));
3835
}
3936

@@ -42,7 +39,7 @@ public void neighbors_givenSurroundedCell_returnsEight() {
4239
for(int x=-1; x < 2; ++x) {
4340
for(int y=-1; y < 2; ++y) {
4441
if (!(0 == x && 0 == y)) {
45-
LifeBoard.value[x + X_POINT][y + Y_POINT] = true;
42+
board.set(x + X_POINT, y + Y_POINT, 1);
4643
}
4744
}
4845
}
@@ -51,7 +48,7 @@ public void neighbors_givenSurroundedCell_returnsEight() {
5148

5249
@Test
5350
public void neighbors_givenLiveCell_doesNotCountItself() {
54-
LifeBoard.value[X_POINT][Y_POINT] = true;
51+
board.set(X_POINT, Y_POINT, 1);
5552
assertThat(engine.neighbors(X_POINT, Y_POINT), is(0));
5653
}
5754

0 commit comments

Comments
 (0)