public void StartNewRound_SecondPlayerCardWins_ShouldAddWinningsToSecondPlayerDeck() { var players = InitializeTwoPlayerGame(); var player1Card = new Card(Suit.Clubs, Rank.Five); var player2Card = new Card(Suit.Clubs, Rank.Nine); players[1].Deck = new List <Card>(); var comparisonResult = new CardComparisonResult(player1Card, player2Card, ComparisonResult.SecondCardWins); var roundWinnings = new List <Card>() { new Card(Suit.Diamonds, Rank.Jack), new Card(Suit.Hearts, Rank.Queen) }; _mockGameRoundService.Setup(mgrs => mgrs.GetResultIfNotEnoughCardsToContinue(It.IsAny <CurrentRound>())).Returns((SingleCardPlayResult)null); _mockGameRoundService.Setup(mgrs => mgrs.AddCardFromAllPlayersToPot(It.IsAny <CurrentRound>())); _mockGameRoundService.Setup(mgrs => mgrs.GetCardDrawResult(It.IsAny <CurrentRound>())).Returns(comparisonResult); _mockGameRoundService.Setup(mgrs => mgrs.GetRoundWinnings(It.IsAny <CurrentRound>())).Returns(roundWinnings); var result = _warGameController.StartNewRound(); _mockGameRoundService.Verify(mgrs => mgrs.GetRoundWinnings(It.IsAny <CurrentRound>()), Times.Once); foreach (var card in roundWinnings) { Assert.Contains(card, players[1].Deck); } }
public void ContinueRoundWithWar_WithEnoughCardsToPlay_ShouldAddCardsToPotTwice() { var players = InitializeTwoPlayerGame(); var comparisonResult = new CardComparisonResult(null, null, ComparisonResult.Tie); _mockGameRoundService.Setup(mgrs => mgrs.GetResultIfNotEnoughCardsToContinue(It.IsAny <CurrentRound>())).Returns((SingleCardPlayResult)null); _mockGameRoundService.Setup(mgrs => mgrs.AddCardFromAllPlayersToPot(It.IsAny <CurrentRound>())); _mockGameRoundService.Setup(mgrs => mgrs.GetCardDrawResult(It.IsAny <CurrentRound>())).Returns(comparisonResult); var result = _warGameController.ContinueRoundWithWar(); _mockGameRoundService.Verify(mgrs => mgrs.AddCardFromAllPlayersToPot(It.IsAny <CurrentRound>()), Times.Exactly(2)); }
public void StartNewRound_CardsAreTied_ShouldRequireWarRound() { var players = InitializeTwoPlayerGame(); var player1Card = new Card(Suit.Clubs, Rank.Ace); var player2Card = new Card(Suit.Clubs, Rank.Nine); var comparisonResult = new CardComparisonResult(player1Card, player2Card, ComparisonResult.Tie); _mockGameRoundService.Setup(mgrs => mgrs.GetResultIfNotEnoughCardsToContinue(It.IsAny <CurrentRound>())).Returns((SingleCardPlayResult)null); _mockGameRoundService.Setup(mgrs => mgrs.AddCardFromAllPlayersToPot(It.IsAny <CurrentRound>())); _mockGameRoundService.Setup(mgrs => mgrs.GetCardDrawResult(It.IsAny <CurrentRound>())).Returns(comparisonResult); var result = _warGameController.StartNewRound(); _mockGameRoundService.Verify(mgrs => mgrs.GetCardDrawResult(It.IsAny <CurrentRound>()), Times.Once); Assert.IsTrue(result.IsWarRequired); Assert.AreEqual(player1Card, result.FirstPlayerCard); Assert.AreEqual(player2Card, result.SecondPlayerCard); }