Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package rules;
- import static org.junit.Assert.*;
- import org.junit.Before;
- import org.junit.Test;
- public class RulesForNextGenerationTest {
- private RulesForNextGeneration inNextGeneration;
- @Before
- public void setup() {
- inNextGeneration = new RulesForNextGeneration();
- }
- @Test
- public void deadCellWith_0_LiveNeighbors_StaysDead() throws Exception {
- assertIsDeadNextTime(new Cell().withLiveNeighbors(0));
- }
- @Test
- public void deadCellWith_1_LiveNeighbors_StaysDead() throws Exception {
- assertIsDeadNextTime(new Cell().withLiveNeighbors(1));
- }
- @Test
- public void deadCellWith_2_LiveNeighbors_StaysDead() throws Exception {
- assertIsDeadNextTime(new Cell().withLiveNeighbors(2));
- }
- @Test
- public void deadCellWith_3_LiveNeighbors_ComesAlive() throws Exception {
- assertIsAliveNextTime(new Cell().withLiveNeighbors(3));
- }
- @Test
- public void deadCellWith_4_LiveNeighbors_staysdead() throws Exception {
- assertIsDeadNextTime(new Cell().withLiveNeighbors(4));
- }
- @Test
- public void liveCellWith_0_LiveNeighbors_Dies() throws Exception {
- assertIsDeadNextTime(new Cell().thatIsAlive().withLiveNeighbors(0));
- }
- @Test
- public void liveCellWith_1_LiveNeighbors_Dies() throws Exception {
- assertIsDeadNextTime(new Cell().thatIsAlive().withLiveNeighbors(1));
- }
- @Test
- public void liveCellWith_2_LiveNeighbors_StaysAlive() throws Exception {
- assertIsAliveNextTime(new Cell().thatIsAlive().withLiveNeighbors(2));
- }
- @Test
- public void liveCellWith_3_LiveNeighbors_StaysAlive() throws Exception {
- assertIsAliveNextTime(new Cell().thatIsAlive().withLiveNeighbors(3));
- }
- @Test
- public void liveCellWith_4_LiveNeighbors_Dies() throws Exception {
- assertIsDeadNextTime(new Cell().thatIsAlive().withLiveNeighbors(4));
- }
- private void assertIsAliveNextTime(Cell cell) {
- assertTrue(inNextGeneration.itTurnsOutThat(cell).comesAlive());
- }
- private void assertIsDeadNextTime(Cell cell) {
- assertFalse(inNextGeneration.itTurnsOutThat(cell).comesAlive());
- }
- // Test list
- // TODO a dead cell with 0 live neighbors stays dead.
- // TODO a dead cell with 1 live neighbors stays dead.
- // TODO a dead cell with 2 live neighbors stays dead.
- // TODO a dead cell with 3 live neighbors comes alive.
- // TODO a dead cell with 4 live neighbors stays dead.
- // TODO a live cell with 0 live neighbors dies.
- // TODO a live cell with 1 live neighbor dies.
- // TODO a live cell with 2 live neighbors stays alive.
- // TODO a live cell with 3 live neighbors stays alive.
- // TODO a live cell with 4 live neighbors dies.
- }
Add Comment
Please, Sign In to add comment