What should happen when, for example, we are facing north and we move the ship forwards? Its location on the y-axis should decrease. Another example would be that when the ship is facing east, it should increase its x-axis location by 1.
The first reaction can be to write specifications similar to the following two:
public void givenNorthWhenMoveForwardThenYDecreases() { ship.moveForward(); assertEquals(ship.getLocation().getPoint().getY(), 12); } public void givenEastWhenMoveForwardThenXIncreases() { ship.getLocation().setDirection(Direction.EAST); ship.moveForward(); assertEquals(ship.getLocation().getPoint().getX(), 22); }
We should create at least two more specifications related to cases where a ship is ...