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.");
        }
Ejemplo n.º 2
0
 private void OnGameStepEvent(object sender, GameStepEventArgs e)
 {
     sleeper.Sleep();
 }