예제 #1
0
        public void NextGeneration_Reproduction_CellRevived()
        {
            // Arrange
            var neighbourCounterSvc = new NeighborCounterServiceBuilder()
                                      .CountReturns(3)   // exactly three live neighbours
                                      .Build();
            var oldGenGrid = new GridBuilder()
                             .WithRows(1)
                             .WithCols(1)
                             .Build();

            // Act
            var sut        = _createTestSubject(neighbourCounterSvc);
            var newGenGrid = sut.NextGeneration(oldGenGrid);

            // Assert: Cell revived due to reproduction
            Assert.IsTrue(newGenGrid[0][0].IsAlive);
        }
예제 #2
0
        public void NextGeneration_With3Neighbours_CellLives()
        {
            // Arrange
            var neighbourCounterSvc = new NeighborCounterServiceBuilder()
                                      .CountReturns(3)
                                      .Build();
            var oldGenGrid = new GridBuilder()
                             .WithRows(1)
                             .WithCols(1)
                             .WithActiveCell(1, 1)
                             .Build();

            // Act
            var sut        = _createTestSubject(neighbourCounterSvc);
            var newGenGrid = sut.NextGeneration(oldGenGrid);

            // Assert
            Assert.IsTrue(newGenGrid[0][0].IsAlive);
        }
예제 #3
0
        public void NextGeneration_Underpopulation_CellDies()
        {
            // Arrange
            var neighbourCounterSvc = new NeighborCounterServiceBuilder()
                                      .CountReturns(Faker.RandomNumber.Next(0, 1))
                                      .Build();
            var oldGenGrid = new GridBuilder()
                             .WithRows(1)
                             .WithCols(1)
                             .WithActiveCell(1, 1)
                             .Build();

            // Act
            var sut        = _createTestSubject(neighbourCounterSvc);
            var newGenGrid = sut.NextGeneration(oldGenGrid);

            // Assert: Died due to underpopulation
            Assert.IsFalse(newGenGrid[0][0].IsAlive);
        }