Exemplo n.º 1
0
        public void Should_KillCell_When_CellHasFewerThanTwoNeighbors()
        {
            // Arrange
            Generation initialGeneration = new Generation(universeSize: 5);
            initialGeneration.ToggleCellLife(0, 0);
            initialGeneration.ToggleCellLife(0, 1);

            // Act
            EvolutionEngine engine = new EvolutionEngine(initialGeneration);
            engine.EvolveGeneration();

            // Assert
            Assert.AreEqual(initialGeneration.GetCell(0, 0).Alive, false);
            Assert.AreEqual(initialGeneration.GetCell(0, 1).Alive, false);
        }
Exemplo n.º 2
0
        public void Should_LetCellLive_When_CellHassTwoOrThreeLiveNeighbours()
        {
            // Arrange
            Generation initialGeneration = new Generation(universeSize: 5);
            initialGeneration.ToggleCellLife(0, 0);
            initialGeneration.ToggleCellLife(0, 1);
            initialGeneration.ToggleCellLife(0, 2);

            // Act
            EvolutionEngine engine = new EvolutionEngine(initialGeneration);
            engine.EvolveGeneration();

            // Assert
            Assert.AreEqual(initialGeneration.GetCell(0, 1).Alive, true);
        }
Exemplo n.º 3
0
        public void Should_MakeCellAlive_When_DeadCellToggled()
        {
            // Arrange
            Generation initialGeneration = new Generation(universeSize: 2);

            // Act
            initialGeneration.ToggleCellLife(0, 0);

            // Assert
            Assert.AreEqual(initialGeneration.GetCell(0, 0).Alive, true);
        }