Example #1
0
 public void CheckEvoluation()
 {
     INeighbourRuleFactory neighbourRuleFactory = new NeighbourRuleFactory();
        IRuleFactory ruleFactory = new RuleFactory();
        GameOfLife Gol = new GameOfLife(grid, ruleFactory, neighbourRuleFactory);
        Gol.Evolve();
        Assert.AreEqual(2, Gol.GenerationNumber);
 }
Example #2
0
 public void GetGridWithNeighbourAliveOfMiddelCell()
 {
     grid = GridHelper.GetGridWithDiagonalNeighbourAliveofMiddleCellDead();
     INeighbourRuleFactory neighbourRuleFactory = new NeighbourRuleFactory();
     IRuleFactory ruleFactory = new RuleFactory();
     GameOfLife Gol = new GameOfLife(grid, ruleFactory, neighbourRuleFactory);
     Gol.Evolve();
     Cell cell = grid[0, 2];
     Assert.AreEqual(false, cell.IsAlive);
 }
Example #3
0
        private static IGameOfLife GetGameOfLifeController(Game grid)
        {
            // Create the neighbourhood rule
            INeighbourRuleFactory neighbourRuleFactory = new NeighbourRuleFactory();

            // Create the rule
            IRuleFactory ruleFactory = new RuleFactory();

            IGameOfLife gameofLifeobject = new GameOfLife(grid, ruleFactory, neighbourRuleFactory);
            return gameofLifeobject;
        }
Example #4
0
 public void GetGridWithDiagonalNeighbourAliveofMiddleCellDead()
 {
     grid = GridHelper.GetGridWithDiagonalNeighbourAliveofMiddleCellDead();
     INeighbourRuleFactory neighbourRuleFactory = new NeighbourRuleFactory();
     IRuleFactory ruleFactory = new RuleFactory();
     GameOfLife Gol = new GameOfLife(grid, ruleFactory, neighbourRuleFactory);
     Gol.Evolve();
     Assert.AreEqual(false, grid[0, 0].IsAlive);
     Gol.Evolve();
     Assert.AreEqual(false, grid[0, 2].IsAlive);
     Gol.Evolve();
     Assert.AreEqual(Gol.GenerationNumber, 4);
 }
Example #5
0
 public void GridWithTopLeftAlive()
 {
     grid = GridHelper.GetGridWithTopLeftAlive();
     INeighbourRuleFactory neighbourRuleFactory = new NeighbourRuleFactory();
     IRuleFactory ruleFactory = new RuleFactory();
     GameOfLife Gol = new GameOfLife(grid, ruleFactory, neighbourRuleFactory);
     Gol.Evolve();
     Assert.AreEqual(false, grid[0, 0].IsAlive);
 }