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 AddRaceToUnknownHero_ThrowsException_Test() { // Arrange var addRaceMessage = RaceMessage.CreateAdd(_sequence.Next, Guid.NewGuid(), new[] { _humanRace }); // Act & Assert Assert.Throws<InvalidActionException>(() => _quest.AddMessage(_gameId, addRaceMessage)); }
public void AddRaceToHeroTwice_ThrowsException_Test() { // Arrange var addRaceMessage = RaceMessage.CreateAdd(_sequence.Next, _playerId, new[] { _humanRace }); var addAnotherRaceMessage = RaceMessage.CreateAdd(_sequence.Next, _playerId, new[] { _humanRace }); // Act & Assert _quest.AddMessage(_gameId, addRaceMessage); Assert.Throws<InvalidActionException>(() => _quest.AddMessage(_gameId, addAnotherRaceMessage)); }
public void AddRaceToHero_ThenUndoIt_ResultsInNoChange_Test() { // Arrange var addRaceMessage = RaceMessage.CreateAdd(_sequence.Next, _playerId, new[] { _humanRace }); // Act _quest.AddMessage(_gameId, addRaceMessage); var game = _quest.Undo(_gameId); // Assert Assert.Empty(game.Score.Heroes.First(x => x.Player.Id == _playerId).Races); }
public void AddRaceToHero_ResultsInAddedRace_Test() { // Arrange var addRaceMessage = RaceMessage.CreateAdd(_sequence.Next, _playerId, new[] { _humanRace }); // Act var game = _quest.AddMessage(_gameId, addRaceMessage); // Assert Assert.Single(game.Score.Heroes.First(x => x.Player.Id == _playerId).Races); Assert.Contains(_humanRace, game.Score.Heroes.First(x => x.Player.Id == _playerId).Races); }
public void AddRaceToHero_ThenSwitchIt_ResultsInSwitchedRace_Test() { // Arrange var addRaceMessage = RaceMessage.CreateAdd(_sequence.Next, _playerId, new[] { _humanRace }); var switchRaceMessage = RaceMessage.Create(_sequence.Next, _playerId, new[] { _dwarfRace }, new[] { _humanRace }); // Act _quest.AddMessage(_gameId, addRaceMessage); var game = _quest.AddMessage(_gameId, switchRaceMessage); // Assert Assert.Single(game.Score.Heroes.First(x => x.Player.Id == _playerId).Races); Assert.Equal(_dwarfRace, game.Score.Heroes.First(x => x.Player.Id == _playerId).Races.First()); }