コード例 #1
0
        public void RecordSurvivorDroppedEquipmentEvent()
        {
            var game     = new Game();
            var survivor = new Survivor("John");

            game.AddSurvivorToGame(survivor);;

            var baseballBat  = EquipmentFactory.GetEquipment(EquipmentType.BaseballBat);
            var katana       = EquipmentFactory.GetEquipment(EquipmentType.Katana);
            var kar98        = EquipmentFactory.GetEquipment(EquipmentType.Kar98);
            var bottledWater = EquipmentFactory.GetEquipment(EquipmentType.BottledWater);
            var knife        = EquipmentFactory.GetEquipment(EquipmentType.Knife);

            survivor.PickUpItem(baseballBat);
            survivor.PickUpItem(katana);
            survivor.PickUpItem(kar98);
            survivor.PickUpItem(bottledWater);
            survivor.PickUpItem(knife);

            var result = survivor.ReceiveWound(1);

            var lastEvent = game.GameHistory.LastOrDefault();

            Assert.IsNotNull(lastEvent);
            Assert.IsTrue(lastEvent.EventDetail.StartsWith($"{survivor.Name} drops a piece of equipment"));
        }
コード例 #2
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!"));
        }
コード例 #3
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);
        }
コード例 #4
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"));
        }