コード例 #1
0
        public void AddNewSurvivorAtStart()
        {
            var game = new Game();
            var John = new Survivor("John");
            var successfullyAddedSurvivor = game.AddSurvivorToGame(John);

            Assert.IsTrue(successfullyAddedSurvivor);
            Assert.AreEqual(1, game.Survivors.Count());
        }
コード例 #2
0
        public void RecordAddingSurvivorToGame()
        {
            var game = new Game();
            var John = new Survivor("John");

            game.AddSurvivorToGame(John);
            var lastEvent = game.GameHistory.LastOrDefault();

            Assert.IsNotNull(lastEvent);
            Assert.IsTrue(lastEvent.EventDetail.StartsWith($"Survivor {John.Name} was added to the game"));
        }
コード例 #3
0
        public void SurvivorYellowThenGameLevelYellow()
        {
            var game   = new Game();
            var John   = new Survivor("John", 15);
            var Whaley = new Survivor("Whaley", 6);

            game.AddSurvivorToGame(John);
            game.AddSurvivorToGame(Whaley);

            Assert.AreEqual(Level.Yellow, game.Level);
        }
コード例 #4
0
        public void SurvivorBlueThenGameLevelBlue()
        {
            var game   = new Game();
            var John   = new Survivor("John", 3);
            var Whaley = new Survivor("Whaley", 6);

            game.AddSurvivorToGame(John);
            game.AddSurvivorToGame(Whaley);

            Assert.AreEqual(Level.Blue, game.Level);
        }
コード例 #5
0
        public void SurvivorsCantHaveTheSameName()
        {
            var game = new Game();
            var John = new Survivor("John");

            game.AddSurvivorToGame(John);

            var newJohn = new Survivor("John");
            var successfullyAddedSurvivor = game.AddSurvivorToGame(newJohn);

            Assert.IsFalse(successfullyAddedSurvivor);
            Assert.AreEqual(1, game.Survivors.Count());
        }
コード例 #6
0
        public void SurvivorRedThenGameLevelRed()
        {
            var game    = new Game();
            var John    = new Survivor("John", 45);
            var Whaley  = new Survivor("Whaley", 6);
            var pumpkin = new Survivor("Pumpkin", 20);

            game.AddSurvivorToGame(John);
            game.AddSurvivorToGame(Whaley);
            game.AddSurvivorToGame(pumpkin);

            Assert.AreEqual(Level.Red, game.Level);
        }
コード例 #7
0
        public void RecordSurvivorKilleded()
        {
            var game     = new Game();
            var survivor = new Survivor("John");

            game.AddSurvivorToGame(survivor);;
            survivor.ReceiveWound(2);

            var lastEvent = game.GameHistory.LastOrDefault();

            Assert.IsNotNull(lastEvent);
            Assert.IsTrue(lastEvent.EventDetail.StartsWith($"{survivor.Name} has been killed!"));
        }
コード例 #8
0
        public void RecordEquipmentPickedUpBySurvivor()
        {
            var game     = new Game();
            var survivor = new Survivor("John");

            game.AddSurvivorToGame(survivor);
            var equipment = EquipmentFactory.GetEquipment(EquipmentType.BaseballBat);

            survivor.PickUpItem(equipment);
            var lastEvent = game.GameHistory.LastOrDefault();

            Assert.IsNotNull(lastEvent);
            Assert.IsTrue(lastEvent.EventDetail.StartsWith($"{survivor.Name} picks up a piece of equipment ({equipment.Name})"));
        }
コード例 #9
0
        public void RecordSurvivorLevelUp()
        {
            var game   = new Game();
            var John   = new Survivor("John", 6);
            var Whaley = new Survivor("Whaley", 10);

            game.AddSurvivorToGame(John);
            game.AddSurvivorToGame(Whaley);
            John.KilledZombie();
            var newLevel = John.Level;

            var lastEvent = game.GameHistory.LastOrDefault();

            Assert.IsNotNull(lastEvent);
            Assert.IsTrue(lastEvent.EventDetail.StartsWith($"{John.Name} has leveled up  and is now {newLevel}"));
        }
コード例 #10
0
        public void AllSurvivorsDead_CheckEndOfGameFlag()
        {
            var game   = new Game();
            var John   = new Survivor("John");
            var Whaley = new Survivor("Whaley");

            game.AddSurvivorToGame(John);
            game.AddSurvivorToGame(Whaley);

            John.ReceiveWound(2);
            Whaley.ReceiveWound(2);

            Assert.IsFalse(John.IsAlive);
            Assert.IsFalse(Whaley.IsAlive);
            Assert.AreEqual(2, game.Survivors.Count());
            Assert.IsTrue(game.IsEndOfGame);
        }
コード例 #11
0
        public void RecordEndOfGame()
        {
            var game   = new Game();
            var John   = new Survivor("John");
            var Whaley = new Survivor("Whaley");

            game.AddSurvivorToGame(John);
            game.AddSurvivorToGame(Whaley);

            John.ReceiveWound(2);
            Whaley.ReceiveWound(2);

            var continueGame = game.GameRound();
            var lastEvent    = game.GameHistory.LastOrDefault();

            Assert.IsFalse(continueGame);
            Assert.IsNotNull(lastEvent);
            Assert.IsTrue(lastEvent.EventDetail.StartsWith("The game has ended, all Survivors died"));
        }
コード例 #12
0
        public void RecordGameLevelUp()
        {
            var game   = new Game();
            var John   = new Survivor("John", 6);
            var Whaley = new Survivor("Whaley", 4);

            game.AddSurvivorToGame(John);
            game.AddSurvivorToGame(Whaley);

            var gameLevelBefore = game.Level;

            John.KilledZombie();
            var newGameLevel = game.Level;

            game.RecordAnyGameLevelChange(gameLevelBefore);
            var lastEvent = game.GameHistory.LastOrDefault();

            Assert.IsNotNull(lastEvent);
            Assert.IsTrue(lastEvent.EventDetail.StartsWith($"The game level is now {newGameLevel}!"));
        }