Пример #1
0
        public void When_the_hand_of_god_touches_a_dead_cell()
        {
            var cell_was_born = false;
            var cell          = Cell.ThatsDeadWithNeighbors(0);

            cell.When_its_born = () => cell_was_born = true;
            cell.Touched();

            Assert.That(cell_was_born, "Touching a dead cell should bring it back to life.");
        }
Пример #2
0
        public void When_a_dead_cell_has_one_neighbors_and_a_moment_passes()
        {
            var cell = Cell.ThatsDeadWithNeighbors(1);

            var cell_died = false;

            cell.When_it_dies = () => cell_died = true;
            cell.MomentPassed();

            Assert.That(cell_died, Is.False, "It should not die when it's already dead.");
        }
Пример #3
0
        public void When_a_dead_cell_has_exactly_three_neighbors()
        {
            var dead_cell = Cell.ThatsDeadWithNeighbors(3);

            var cell_was_born = false;

            dead_cell.When_its_born = () => cell_was_born = true;
            dead_cell.MomentPassed();

            Assert.That(cell_was_born, "it should come to life");
        }
Пример #4
0
        public void When_a_dead_cell_has_exactly_three_neighbors_and_more_than_one_moment_passes()
        {
            var dead_cell = Cell.ThatsDeadWithNeighbors(3);

            var number_of_times_born = 0;

            dead_cell.When_its_born = () => number_of_times_born++;
            dead_cell.MomentPassed();
            dead_cell.MomentPassed();

            Assert.That(number_of_times_born, Is.EqualTo(1), "it should be born only once.");
        }
        private void CreateDeadCellsWhereThereAreNoneSurrounding(KeyValuePair <Location, Cell> born_location)
        {
            var locations = born_location.Key.GetNeighboringLocations();

            foreach (var location in locations)
            {
                if (!cell_locations.Exists(x => x.Key.Equals(location)))
                {
                    var dead_cell = Cell.ThatsDeadWithNeighbors(0);
                    AddCellToWorld(location, dead_cell);
                }
            }
        }
Пример #6
0
        public void When_a_neighboring_cell_dies_without_knowing_of_any_neighbors()
        {
            var cell_born = false;
            var cell      = Cell.ThatsDeadWithNeighbors(0);

            cell.When_its_born = () => cell_born = true;
            cell.NeighborDied();
            cell.NeighborWasBorn();
            cell.NeighborWasBorn();
            cell.NeighborWasBorn();
            cell.MomentPassed();

            Assert.That(cell_born, "it should count neighbors up from zero and not go into negatives.");
        }