public void StepForward_GivenEmptyUniverse_ResultsInEmptyUniverse()
        {
            // arrange
            var game = new LinqGame(new StandardRules());

            // act
            game.StepForward();

            // assert
            Assert.AreEqual(
                expected: 0,
                actual: game.Population,
                message: "The universe is not empty.");

            Assert.AreEqual(
                expected: 1,
                actual: game.Generation,
                message: "The game did not progress by one generation.");
        }
        public void StepForward_GivenFivePointAndEventHandler_ResultsInPopulationOfFourAndFiveRemoved()
        {
            // arrange
            var pattern = new FivePoint();
            var game = new LinqGame(new StandardRules());

            object sender = null;
            GameStepEventArgs eventArgs = null;
            EventHandler<GameStepEventArgs> handler = (object s, GameStepEventArgs e) =>
                {
                    sender = s;
                    eventArgs = e;
                };

            game.InitializeFrom(pattern.GetPattern());
            game.GameStepEvent += handler;

            // act
            game.StepForward();

            // assert
            Assert.AreEqual(
                expected: 4,
                actual: game.Population,
                message: "The universe does not contain exactly 4 cells.");

            Assert.AreSame(
                expected: game,
                actual: sender,
                message: "Incorrect sender reference in event handler.");

            Assert.AreEqual(
                expected: 5,
                actual: eventArgs.DeadCells.Count(),
                message: "The set of removed cells does not contain exactly 5 cells.");

            Assert.AreEqual(
                expected: 4,
                actual: eventArgs.NewCells.Count(),
                message: "The set of added cells does not contain exactly 4 cells.");
        }
        public void StepForward_GivenEventHandlerIsAttached_CallsHandler()
        {
            // arrange
            var mockRules = new Mock<RulesBase>(new[] { 1 }, new[] { 2 });
            var game = new LinqGame(mockRules.Object);

            int numberOfTimesCalled = 0;
            game.GameStepEvent += (sender, args) => { ++numberOfTimesCalled; };

            // act
            game.StepForward();

            // assert
            Assert.AreEqual(1, numberOfTimesCalled);
        }
        public void StepForward_GivenFivePoint_ResultsInPopulationOfFour()
        {
            // arrange
            var pattern = new FivePoint();
            var game = new LinqGame(new StandardRules());
            game.InitializeFrom(pattern.GetPattern());

            // act
            game.StepForward();

            // assert
            Assert.AreEqual(
                expected: 4,
                actual: game.Population,
                message: "The universe does not contain exactly 4 cells.");

            Assert.AreEqual(
                expected: 1,
                actual: game.Generation,
                message: "The game did not progress by one generation.");
        }