Package dojo.gameoflife.a20111203gdcr3

Source Code of dojo.gameoflife.a20111203gdcr3.RulesTest

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

}
TOP

Related Classes of dojo.gameoflife.a20111203gdcr3.RulesTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.