public void Should_update_tiles_after_processing_rules() { var gameData = CreateData(); var gameResultService = new Mock <IGameResultService>(); var tiles = Enumerable.Range(0, 9) .Select(x => new Tile { TileId = x, Element = Element.Fire }); var ruleStrategy = new Mock <IRuleStrategy>(); ruleStrategy .Setup(x => x.Apply( It.IsAny <IEnumerable <Tile> >(), It.IsAny <int>())) .Returns(tiles); var ruleStrategyFactory = new Mock <IRuleStrategyFactory>(); ruleStrategyFactory .Setup(x => x.Create(It.IsAny <IEnumerable <Rule> >())) .Returns(ruleStrategy.Object); var subject = new PlayCardHandler( gameResultService.Object, ruleStrategyFactory.Object); var data = subject.Run(CreateStep(gameData)); data.Tiles.Should().BeEquivalentTo(tiles); }
public void Should_switch_turn(bool isHost) { var gameData = CreateData(isHost); var gameResultService = new Mock <IGameResultService>(); var ruleStrategyFactory = new Mock <IRuleStrategyFactory>(); ruleStrategyFactory .Setup(x => x.Create(It.IsAny <IEnumerable <Rule> >())) .Returns(CreateRuleStrategy()); var subject = new PlayCardHandler( gameResultService.Object, ruleStrategyFactory.Object); var data = subject.Run(CreateStep(gameData, isHost: isHost)); data.HostTurn.Should().Be(!isHost); }
public void Should_have_correct_move_log_entry(bool isHost, int tileId, string message) { var gameData = CreateData(isHost); var gameResultService = new Mock <IGameResultService>(); var ruleStrategyFactory = new Mock <IRuleStrategyFactory>(); ruleStrategyFactory .Setup(x => x.Create(It.IsAny <IEnumerable <Rule> >())) .Returns(CreateRuleStrategy()); var subject = new PlayCardHandler( gameResultService.Object, ruleStrategyFactory.Object); var data = subject.Run(CreateStep(gameData, isHost: isHost, tileId: tileId)); data.Log.Should().Contain(message); }
public void Should_have_player_assigned_to_card(bool isHost) { var gameData = CreateData(isHost); var gameResultService = new Mock <IGameResultService>(); var ruleStrategyFactory = new Mock <IRuleStrategyFactory>(); ruleStrategyFactory .Setup(x => x.Create(It.IsAny <IEnumerable <Rule> >())) .Returns(CreateRuleStrategy()); var subject = new PlayCardHandler( gameResultService.Object, ruleStrategyFactory.Object); var data = subject.Run(CreateStep(gameData, isHost: isHost)); var tile = data.Tiles.Single(x => x.TileId == 0); tile.Card.IsHost.Should().Be(isHost); }
public void Should_assign_card_to_tile(int tileId) { var gameData = CreateData(); var gameResultService = new Mock <IGameResultService>(); var ruleStrategyFactory = new Mock <IRuleStrategyFactory>(); ruleStrategyFactory .Setup(x => x.Create(It.IsAny <IEnumerable <Rule> >())) .Returns(CreateRuleStrategy()); var subject = new PlayCardHandler( gameResultService.Object, ruleStrategyFactory.Object); var data = subject.Run(CreateStep(gameData, tileId: tileId)); var tile = data.Tiles.Single(x => x.TileId == tileId); tile.Card.Should().BeEquivalentTo(Card, options => options.ExcludingMissingMembers()); }
public void Should_have_remove_card_from_hand(bool isHost) { var gameData = CreateData(isHost); var gameResultService = new Mock <IGameResultService>(); var ruleStrategyFactory = new Mock <IRuleStrategyFactory>(); ruleStrategyFactory .Setup(x => x.Create(It.IsAny <IEnumerable <Rule> >())) .Returns(CreateRuleStrategy()); var subject = new PlayCardHandler( gameResultService.Object, ruleStrategyFactory.Object); var data = subject.Run(CreateStep(gameData, isHost: isHost)); var cards = isHost ? data.HostCards : data.ChallengerCards; var expectedCards = (isHost ? HostCards : ChallengerCards) .Where(x => x.Name != Card.Name); cards.Should().BeEquivalentTo(expectedCards); }
public void Should_have_correct_result(Result?result) { var gameData = CreateData(); var gameResultService = new Mock <IGameResultService>(); gameResultService .Setup(x => x.GetResult(It.IsAny <GameData>())) .Returns(result); var ruleStrategyFactory = new Mock <IRuleStrategyFactory>(); ruleStrategyFactory .Setup(x => x.Create(It.IsAny <IEnumerable <Rule> >())) .Returns(CreateRuleStrategy()); var subject = new PlayCardHandler( gameResultService.Object, ruleStrategyFactory.Object); var data = subject.Run(CreateStep(gameData)); data.Result.Should().Be(result); }