public void PlayerShouldNotJoinToOvercrowdedGame() { var game = GameMocks.Overcrowded(); var processor = new JoinEventProcessor(game.Object, new MockLogger()); var errorEvent = (ErrorEvent)processor.Process(new JoinEvent()); Assert.Equal(Constants.Messages.GameOvercrowded, errorEvent.Message); }
public void IncorrectParametersShouldProduceError() { var game = GameMocks.Empty(); var processor = CreateProcessor(game); var result = (ErrorEvent)processor.Process(new HealingEvent(1, 2)); Assert.Equal(string.Format(Constants.Messages.PlayerNotFoundTemplate, 1), result.Message); }
public void PlayerShouldJoin() { var game = GameMocks.Joinable(); var processor = new JoinEventProcessor(game.Object, new MockLogger()); var joinedEvent = (PlayerJoinedEvent)processor.Process(new JoinEvent()); Assert.NotNull(joinedEvent.Player); }
public void SelfAttackShouldProduceError() { var game = GameMocks.TwoPlayers(); var processor = CreateProcessor(game); var result = (ErrorEvent)processor.Process(new AttackEvent(1, 1)); Assert.Equal(Constants.Messages.CannotAttackSelf, result.Message); }
public void PlayerCanJoinFaction() { var game = GameMocks.Joinable(); var processor = new JoinFactionEventProcessor(game.Object); var joinedEvent = (PlayerJoinedEvent)processor.Process(new JoinEvent()); Assert.NotNull(joinedEvent.Player); }
public void HealingShouldBeLimited() { var game = GameMocks.TwoPlayers(); var processor = CreateProcessor(game); var result = (PlayerHealedEvent)processor.Process(new HealingEvent(1, 1)); Assert.Equal(1, result.PlayerId); Assert.Equal(1000, result.Health); Assert.Equal(string.Format(Constants.Messages.HealedTemplate, 1, 1), result.Message); }
public void HealingShouldIncreaseHealth() { var game = GameMocks.TwoPlayersOneDamaged(); var processor = CreateProcessor(game); var result = (PlayerHealedEvent)processor.Process(new HealingEvent(2, 2)); Assert.Equal(2, result.PlayerId); Assert.InRange(result.Health, 600, 700); Assert.Equal(string.Format(Constants.Messages.HealedTemplate, 2, 2), result.Message); }
public void KillingShouldProduceCorrectMessage() { var game = GameMocks.TwoPlayersOneDamaged(); var processor = CreateProcessor(game); var result = (PlayerDamagedEvent)processor.Process(new AttackEvent(1, 2)); Assert.Equal(0, result.Health); Assert.Equal(string.Format(Constants.Messages.AttackedTemplate, 1, 2) + " " + string.Format(Constants.Messages.KilledTemplate, 2), result.Message); }
public void AttackShouldCauseDamage() { var game = GameMocks.TwoPlayers(); var processor = CreateProcessor(game); var result = (PlayerDamagedEvent)processor.Process(new AttackEvent(1, 2)); Assert.Equal(2, result.PlayerId); Assert.InRange(result.Health, 0, 500); Assert.StartsWith(string.Format(Constants.Messages.AttackedTemplate, 1, 2), result.Message); }