Example #1
0
  @Test
  public void aCellAliveTest() {
    // GIVEN
    Cell cell = new Cell();

    // WHEN
    boolean status = cell.isAlive();

    // THEN
    assertFalse("A new cell is dead", status);
  }
Example #2
0
  public void aDeadCellWith2NeighboursStaysDeadTest() {
    // GIVEN
    int numberOfNeighbours = 2;
    Cell cell = new Cell(false, numberOfNeighbours);

    // WHEN
    cell.nextStep();
    boolean status = cell.isAlive();

    // THEN
    assertFalse("A cell with 2 neighbours stays dead", status);
  }
Example #3
0
  @Test
  public void aCellLivesWith3NeighboursTest() {
    // GIVEN
    int numberOfNeighbours = 3;
    Cell cell = new Cell(true, numberOfNeighbours);

    // WHEN
    cell.nextStep();
    boolean status = cell.isAlive();

    // THEN
    assertTrue("A cell with 3 neighbours lives or is reanimated", status);
  }
Example #4
0
  @Test
  public void shouldReturnFalseIfCellIsDeadWhenIsAliveIsCalled() {
    Cell cell = new Cell(false);

    assertFalse(cell.isAlive());
  }
Example #5
0
  @Test
  public void shouldReturnTrueIfCellIsAliveWhenIsAliveIsCalled() {
    Cell cell = new Cell(true);

    assertTrue(cell.isAlive());
  }