コード例 #1
0
        public void Game_Allows_Addition_Of_Survivors()
        {
            sut = new GameController();

            var newSurvivor = new Survivor("Kyle");

            sut.AddSurvivor(newSurvivor);

            sut.Survivors.Count.Should().Be(1);
        }
コード例 #2
0
        public void AddSurvivor(Survivor survivor)
        {
            if (Survivors.Any(s => s.Name == survivor.Name))
            {
                return;
            }

            Survivors.Add(survivor);
            History.LogEvent(new HistoryEvent(survivor.Name, nameof(Survivor), "ADDED_TO_GAME"));
        }
コード例 #3
0
        public void Survivor_Exceeds_Six_Experience_Should_Advance_To_Yellow()
        {
            sut = new GameController();
            var firstSurvivor = new Survivor("Kyle");

            sut.AddSurvivor(firstSurvivor);

            sut.KillZombie(firstSurvivor, 7);

            firstSurvivor.CurrentLevel.Should().Be("Yellow");
        }
コード例 #4
0
        public void Survivor_Exceeds_FortyTwo_Experience_Should_Advance_To_Red()
        {
            sut = new GameController();
            var firstSurvivor = new Survivor("Kyle");

            sut.AddSurvivor(firstSurvivor);

            sut.KillZombie(firstSurvivor, 43);

            firstSurvivor.CurrentLevel.Should().Be("Red");
        }
コード例 #5
0
        public void Survivor_Exceeds_Eighteen_Experience_Should_Advance_To_Orange()
        {
            sut = new GameController();
            var firstSurvivor = new Survivor("Kyle");

            sut.AddSurvivor(firstSurvivor);

            sut.KillZombie(firstSurvivor, 19);

            firstSurvivor.CurrentLevel.Should().Be("Orange");
        }
コード例 #6
0
        public void Survivor_Should_Gain_One_Experience_When_They_Kill_A_Zombie()
        {
            sut = new GameController();
            var firstSurvivor = new Survivor("Kyle");

            sut.AddSurvivor(firstSurvivor);
            int expectedExperience = firstSurvivor.Experience + 1;

            sut.KillZombie(firstSurvivor, 1);

            firstSurvivor.Experience.Should().Be(expectedExperience);
        }
コード例 #7
0
        public void Game_Does_Not_Allow_Duplicate_Survivors()
        {
            var firstSurvivor     = new Survivor("Kyle");
            var secondSurvivor    = new Survivor("Nathan");
            var duplicateSurvivor = new Survivor("Nathan");

            sut.AddSurvivor(firstSurvivor);
            sut.AddSurvivor(secondSurvivor);
            sut.AddSurvivor(duplicateSurvivor);

            sut.Survivors.Count.Should().Be(2);
        }
コード例 #8
0
        public void Game_History_Notes_A_Suvivor_Has_Been_Added_To_Game()
        {
            sut = new GameController();

            var newSurvivor = new Survivor("Kyle");

            sut.AddSurvivor(newSurvivor);

            var addSurvivorEvent = sut.History.Events.FirstOrDefault(e => e.EntityId == "Kyle");

            addSurvivorEvent.EntityId.Should().Be("Kyle");
            addSurvivorEvent.EntityType.Should().Be(nameof(Survivor));
            addSurvivorEvent.Message.Should().Be("ADDED_TO_GAME");
        }
コード例 #9
0
        public void Game_Level_Equals_Highest_Living_Survivor_Level()
        {
            sut = new GameController();

            var firstSurvivor  = new Survivor("Kyle");
            var secondSurvivor = new Survivor("Nathan");

            sut.AddSurvivor(firstSurvivor);
            sut.AddSurvivor(secondSurvivor);

            sut.KillZombie(firstSurvivor, 1);
            sut.KillZombie(secondSurvivor, 8);

            sut.CurrentLevel.Should().Be("Yellow");
        }