diff --git a/README.md b/README.md index ed168ec..9138cd1 100644 --- a/README.md +++ b/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 @@ -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. \ No newline at end of file +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. diff --git a/src/test/java/EngineTest.java b/src/test/java/EngineTest.java index 7aeefe9..0f3bdca 100644 --- a/src/test/java/EngineTest.java +++ b/src/test/java/EngineTest.java @@ -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 @@ -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)); } @@ -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); } } } @@ -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)); }