public void LevelUpHeroThenKillHim_ResultsInClassesAndRacesUnchanged_Test()
        {
            // Arrange
            var dwarf  = "Dwarf";
            var priest = "Priest";
            var quest  = QuestFactory.CreateStartedWithMaleHero(
                out var gameStore,
                out var gameId,
                out var playerId,
                out var sequence);

            var raceMessage  = RaceMessage.CreateAdd(sequence.Next, playerId, new[] { dwarf });
            var classMessage = ClassMessage.CreateAdd(sequence.Next, playerId, new[] { priest });
            var deathMsg     = DeathMessage.Create(sequence.Next, playerId);

            // Act
            quest.AddMessage(gameId, raceMessage);
            quest.AddMessage(gameId, classMessage);
            var game = quest.AddMessage(gameId, deathMsg);

            // Assert
            var hero = game.GetHero(playerId);

            Assert.Single(hero.Races);
            Assert.Single(hero.Classes);
        }
        public void AddClassToUnknownHero_ThrowsException_Test()
        {
            // Arrange
            var addClassMessage = ClassMessage.CreateAdd(_sequence.Next, Guid.NewGuid(), new[] { _warriorClass });

            // Act & Assert
            Assert.Throws<InvalidActionException>(() => _quest.AddMessage(_gameId, addClassMessage));
        }
        public void AddClassToHeroTwice_ThrowsException_Test()
        {
            // Arrange
            var addClassMessage = ClassMessage.CreateAdd(_sequence.Next, _playerId, new[] { _warriorClass });
            var addAnotherClassMessage = ClassMessage.CreateAdd(_sequence.Next, _playerId, new[] { _warriorClass });

            // Act & Assert
            _quest.AddMessage(_gameId, addClassMessage);
            Assert.Throws<InvalidActionException>(() => _quest.AddMessage(_gameId, addAnotherClassMessage));
        }
        public void AddClassToHero_ResultsInAddedClass_Test()
        {
            // Arrange
            var addClassMessage = ClassMessage.CreateAdd(_sequence.Next, _playerId, new[] { _warriorClass });

            // Act
            var game = _quest.AddMessage(_gameId, addClassMessage);

            // Assert
            Assert.Single(game.Score.Heroes.First(x => x.Player.Id == _playerId).Classes);
            Assert.Contains(_warriorClass, game.Score.Heroes.First(x => x.Player.Id == _playerId).Classes);
        }
        public void AddClassToHero_ThenUndoIt_ResultsInNoChange_Test()
        {
            // Arrange
            var addClassMessage = ClassMessage.CreateAdd(_sequence.Next, _playerId, new[] { _warriorClass });

            // Act
            _quest.AddMessage(_gameId, addClassMessage);
            var game = _quest.Undo(_gameId);

            // Assert
            Assert.Empty(game.Score.Heroes.First(x => x.Player.Id == _playerId).Classes);
        }
        public void AddClassToHero_ThenSwitchClasses_ResultsInSwitchedClass_Test()
        {
            // Arrange
            var addClassMessage = ClassMessage.CreateAdd(_sequence.Next, _playerId, new[] { _warriorClass });
            var switchClassMessage = ClassMessage.Create(_sequence.Next, _playerId, new[] { _thiefClass }, new[] { _warriorClass });

            // Act
            _quest.AddMessage(_gameId, addClassMessage);
            var game = _quest.AddMessage(_gameId, switchClassMessage);

            // Assert
            Assert.Single(game.Score.Heroes.First().Classes);
            Assert.Equal(_thiefClass, game.Score.Heroes.First().Classes.First());
        }