Skip to content

Commit

Permalink
Engine Tests Converted
Browse files Browse the repository at this point in the history
  • Loading branch information
ClayDowling committed Apr 15, 2017
1 parent 565fd5c commit 1943147
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
8 changes: 6 additions & 2 deletions README.md
@@ -1,6 +1,6 @@
# branch-by-abstraction

A demonstration of branching by abstration
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.

## Initial State

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

## Partially Transition

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.
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.

## Engine Tests Converted

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.
15 changes: 6 additions & 9 deletions src/test/java/EngineTest.java
Expand Up @@ -13,17 +13,14 @@ public class EngineTest {
static final int Y_POINT = 10;

private Engine engine;
private LifeBoard board;

@Before
public void setUp() {
engine = new Engine();
board = new LifeBoard();

for(int x = 0; x < LifeBoard.X_MAX; ++x) {
for(int y = 0; y < LifeBoard.Y_MAX; ++y) {
LifeBoard.value[x][y] = false;
}
}

board.clear();
}

@Test
Expand All @@ -33,7 +30,7 @@ public void neighbors_givenEmptyBoard_returnsZero() {

@Test
public void neighbors_givenOneNeighbor_returnsOne() {
LifeBoard.value[9][9] = true;
board.set(9,9, 1);
assertThat(engine.neighbors(X_POINT, Y_POINT), is(1));
}

Expand All @@ -42,7 +39,7 @@ public void neighbors_givenSurroundedCell_returnsEight() {
for(int x=-1; x < 2; ++x) {
for(int y=-1; y < 2; ++y) {
if (!(0 == x && 0 == y)) {
LifeBoard.value[x + X_POINT][y + Y_POINT] = true;
board.set(x + X_POINT, y + Y_POINT, 1);
}
}
}
Expand All @@ -51,7 +48,7 @@ public void neighbors_givenSurroundedCell_returnsEight() {

@Test
public void neighbors_givenLiveCell_doesNotCountItself() {
LifeBoard.value[X_POINT][Y_POINT] = true;
board.set(X_POINT, Y_POINT, 1);
assertThat(engine.neighbors(X_POINT, Y_POINT), is(0));
}

Expand Down

0 comments on commit 1943147

Please sign in to comment.