package dojo.gameoflife.a20111203gdcr3;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import org.junit.Before;
import org.junit.Test;
import dojo.gameoflife.a20111203gdcr3.model.Rules;
import dojo.gameoflife.a20111203gdcr3.model.State;
import dojo.gameoflife.a20111203gdcr3.model.Will;
public class RulesTest {
private Rules rules;
@Before
public void forEachTestCreateRules() {
rules = new Rules(State.ALIVE);
}
@Test
public void whenLessThanTwoNeighboursThenCellDies() {
// arrange - see setup()
// act
rules.observeNeighbours(1);
// assert
assertThat(rules.decides(), is(Will.DIE));
}
@Test
public void whenTwoLivingNeighboursThenCellLivesOn() {
// arrange - see setup()
// act
rules.observeNeighbours(2);
// assert
assertThat(rules.decides(), is(Will.LIVE_ON));
}
@Test
public void whenThreeLivingNeighboursThenCellLivesOn() {
// arrange - see setup()
// act
rules.observeNeighbours(3);
// assert
assertThat(rules.decides(), is(Will.LIVE_ON));
}
@Test
public void whenFourLivingNeighboursThenCellDies() {
// arrange - see setup()
// act
rules.observeNeighbours(4);
// assert
assertThat(rules.decides(), is(Will.DIE));
}
@Test
public void whenDeadCellWithExactlyThreeLivingNeighboursThenItIsReborn() {
// arrange - see setup()
rules = new Rules(State.DEAD);
// act
rules.observeNeighbours(3);
// assert
assertThat(rules.decides(), is(Will.REBORN));
}
// unfinished
}