Permalink
Browse files

Engine Tests Converted

  • Loading branch information...
1 parent 565fd5c commit 19431478354d7395d68a44299c53a1029a51cc22 @ClayDowling ClayDowling committed Apr 15, 2017
Showing with 12 additions and 11 deletions.
  1. +6 −2 README.md
  2. +6 −9 src/test/java/EngineTest.java
View
@@ -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.
+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.
@@ -13,17 +13,14 @@
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));
}

0 comments on commit 1943147

Please sign in to comment.