public void StartAFight_ThenAnotherPlayerJoins_ResultsInRaisedHeroStrength_Test() { var quest = QuestFactory.CreateStartedWithMaleHero( out var gameStore, out var gameId, out var playerId, out var sequence); var xena = new Hero(PlayerFactory.CreateFemale("Xena")); var game = quest.GetState(gameId); var hero = game.GetHero(playerId); var heroLevelRaise = LevelMessage.Create(sequence.Next, playerId, 1); var heroBonusRaise = BonusMessage.Create(sequence.Next, playerId, 1); var addXena = PlayerMessage.CreateAdd(sequence.Next, new[] { xena.Player }); var xenaLevelRaise = LevelMessage.Create(sequence.Next, xena.Player.Id, 1); var xenaBonusRaise = BonusMessage.Create(sequence.Next, xena.Player.Id, 1); var startFight = FightStartMessage.Create(sequence.Next, hero.Player.Id, zerschmetterling); var preparation = new GameMessage[] { heroLevelRaise, heroBonusRaise, addXena, xenaLevelRaise, xenaBonusRaise, startFight }; var xenaJoinsFight = FightJoinMessage.Create(sequence.Next, xena.Player.Id); quest.AddMessages(gameId, preparation); game = quest.AddMessage(gameId, xenaJoinsFight); Assert.NotNull(game.Score.Fight); Assert.Equal(2, game.Score.Fight.Heroes.Count); Assert.Equal(6, game.Score.Fight.TotalHeroesScore); }
private static void addMaleHeroToQuest(Quest quest, Sequence sequence, Guid gameId, out Guid playerId) { var player = PlayerFactory.CreateMale("John Doe"); var heroAddMsg = PlayerMessage.CreateAdd(sequence.Next, new[] { player }); quest.AddMessage(gameId, heroAddMsg); playerId = player.Id; }
public void LetHeroDieBeforeGameStarted_ThrowsException_Test() { // Arrange var quest = QuestFactory.CreateStored(out var gameStore, out var gameId); var playerMsg = PlayerMessage.CreateAdd(1, new[] { someDude }); var deathMsg = DeathMessage.Create(2, someDude.Id); // Act & Assert quest.AddMessage(gameId, playerMsg); Assert.Throws <InvalidActionException>(() => quest.AddMessage(gameId, deathMsg)); }
public void AddSameHeroTwice_ThrowsException_Test() { // Arrange var quest = QuestFactory.CreateStored(out var gameStore, out var gameId); var addBonnie = PlayerMessage.CreateAdd(1, new[] { bonnie }); var addAnotherBonnie = PlayerMessage.CreateAdd(2, new[] { bonnie }); // Act & Assert quest.AddMessage(gameId, addBonnie); Assert.Throws <InvalidActionException>(() => quest.AddMessage(gameId, addAnotherBonnie)); }
public void AddHero_ThenUndoId_ResultsInEmptyGame_Test() { // Arrange var quest = QuestFactory.CreateStored(out var gameStore, out var gameId); var addHero = PlayerMessage.CreateAdd(1, new[] { bonnie }); // Act quest.AddMessage(gameId, addHero); var game = quest.Undo(gameId); // Assert Assert.Empty(game.Score.Heroes); }
public void AddTwoHeroes_ResultsInTwoAddedHeroes_Test() { // Arrange var quest = QuestFactory.CreateStored(out var gameStore, out var gameId); var addBonnie = PlayerMessage.CreateAdd(1, new[] { bonnie }); var addClyde = PlayerMessage.CreateAdd(2, new[] { clyde }); // Act quest.AddMessage(gameId, addBonnie); var game = quest.AddMessage(gameId, addClyde); // Assert Assert.Equal(2, game.Score.Heroes.Count); }
public void AddHeroToGame_ResultsInAddedHero_Test() { // Arrange var quest = QuestFactory.CreateStored(out var gameStore, out var gameId); var addHero = PlayerMessage.CreateAdd(1, new[] { bonnie }); // Act var game = quest.AddMessage(gameId, addHero); // Assert Assert.Single(game.Score.Heroes); Assert.Equal(bonnie.Name, game.Score.Heroes.First().Player.Name); Assert.Equal(bonnie.Gender, game.Score.Heroes.First().Player.Gender); }
public void AddTwoHeroes_ThenUndoIt_ResultsInNoChange_Test() { // Arrange var quest = QuestFactory.CreateStored(out var gameStore, out var gameId); var addBonnie = PlayerMessage.CreateAdd(1, new[] { bonnie }); var addClyde = PlayerMessage.CreateAdd(2, new[] { clyde }); // Act quest.AddMessage(gameId, addBonnie); quest.AddMessage(gameId, addClyde); var game = quest.Undo(gameId); // Assert Assert.Single(game.Score.Heroes); }
public void AddHero_ThenRemoveHim_ThenUndoIt_ResultsInAddedHero_Test() { // Arrange var quest = QuestFactory.CreateStored(out var gameStore, out var gameId); var addBonnie = PlayerMessage.CreateAdd(1, new[] { bonnie }); var removeBonnie = PlayerMessage.CreateRemove(2, new[] { bonnie }); // Act quest.AddMessage(gameId, addBonnie); quest.AddMessage(gameId, removeBonnie); var game = quest.Undo(gameId); // Assert Assert.Single(game.Score.Heroes); Assert.Equal(bonnie.Name, game.Score.Heroes.First().Player.Name); Assert.Equal(bonnie.Gender, game.Score.Heroes.First().Player.Gender); }