public void PlayCardEstimator_PlayOneRankedCardInDefaultIfPossible_ReturnsOne(int blowCounter) { // arrange var blueOneCard = new Card(Color.Blue, Rank.One); var whiteTwoCard = new Card(Color.White, Rank.Two); var blueThreeCard = new Card(Color.Blue, Rank.Three); var gameProvider = GameProviderFabric.Create(Color.White, Color.Blue); var playStrategyStub = InitPlayStrategy(gameProvider); playStrategyStub.AddCardInHand(blueOneCard); playStrategyStub.AddCardInHand(whiteTwoCard); playStrategyStub.AddCardInHand(blueThreeCard); var dict = new Dictionary <Card, Probability> { { blueOneCard, new Probability(0.2) }, { whiteTwoCard, new Probability(0.3) }, { blueThreeCard, new Probability(0.4) }, }; SetProbabilities(playStrategyStub, dict); var boardContext = new BoardContextStub { ExpectedCards = new[] { new Card(Color.Blue, Rank.One), new Card(Color.White, Rank.Two), }, BlowCounter = blowCounter }; var playerContext = PlayerContextFabric.CreateStub(playStrategyStub.Player, playStrategyStub.Hand); var clueAboutOneRank = new ClueAboutRank(Rank.One); var blueOneInHand = playStrategyStub.Hand.First(card => card.Card == blueOneCard); playerContext.CluesAboutCard[blueOneInHand] = new List <ClueType> { clueAboutOneRank }; // act var playCardEstimator = new PlayCardEstimator(playStrategyStub); var possibleCards = playCardEstimator.GetPossibleCards(boardContext, playerContext).ToList(); // assert Assert.IsTrue(possibleCards.Count == 1); Assert.AreEqual(blueOneCard, possibleCards.First()); }
public void PlayCardEstimator_TwoSubtleCluesWithDifferentProbabilies_ReturnsTwoCards() { // arrange var blueOneCard = new Card(Color.Blue, Rank.One); var whiteTwoCard = new Card(Color.White, Rank.Two); var blueThreeCard = new Card(Color.Blue, Rank.Three); var whiteFourCard = new Card(Color.White, Rank.Four); var gameProvider = GameProviderFabric.Create(Color.White, Color.Blue); var playStrategyStub = InitPlayStrategy(gameProvider); playStrategyStub.AddCardInHand(blueOneCard); playStrategyStub.AddCardInHand(whiteTwoCard); playStrategyStub.AddCardInHand(blueThreeCard); playStrategyStub.AddCardInHand(whiteFourCard); var dict = new Dictionary <Card, Probability> { { blueOneCard, new Probability(0.2) }, { whiteTwoCard, new Probability(0.3) }, { blueThreeCard, new Probability(0.4) }, { whiteFourCard, new Probability(0.5) } }; SetProbabilities(playStrategyStub, dict); var playerContext = PlayerContextFabric.CreateStub(playStrategyStub.Player, playStrategyStub.Hand); playerContext.IsSubtleCluePredicate = cardInHand => new [] { blueOneCard, whiteTwoCard }.Contains(cardInHand.Card); var boardContext = new BoardContextStub(); // act var playCardEstimator = new PlayCardEstimator(playStrategyStub); var possibleCards = playCardEstimator.GetPossibleCards(boardContext, playerContext); // assert Assert.AreEqual(2, possibleCards.Count); Assert.IsTrue(possibleCards.Contains(blueOneCard)); Assert.IsTrue(possibleCards.Contains(whiteTwoCard)); }
public void PlayCardEstimator_NoSubtleCluesAndAllProbabilitiesLessThanThreshold_ReturnsEmpty() { // arrange var blueOneCard = new Card(Color.Blue, Rank.One); var whiteTwoCard = new Card(Color.White, Rank.Two); var blueThreeCard = new Card(Color.Blue, Rank.Three); var whiteFourCard = new Card(Color.White, Rank.Four); var gameProvider = GameProviderFabric.Create(Color.White, Color.Blue); var playStrategyStub = InitPlayStrategy(gameProvider); playStrategyStub.AddCardInHand(blueOneCard); playStrategyStub.AddCardInHand(whiteTwoCard); playStrategyStub.AddCardInHand(blueThreeCard); playStrategyStub.AddCardInHand(whiteFourCard); var dict = new Dictionary <Card, Probability> { { blueOneCard, new Probability(0.2) }, { whiteTwoCard, new Probability(0.3) }, { blueThreeCard, new Probability(0.4) }, { whiteFourCard, new Probability(0.5) } }; SetProbabilities(playStrategyStub, dict); var boardContext = new BoardContextStub { ExpectedCards = new[] { new Card(Color.Blue, Rank.One), new Card(Color.White, Rank.One), } }; var playerContext = PlayerContextFabric.CreateStub(playStrategyStub.Player, playStrategyStub.Hand); // act var playCardEstimator = new PlayCardEstimator(playStrategyStub); var possibleCards = playCardEstimator.GetPossibleCards(boardContext, playerContext); // assert Assert.IsTrue(!possibleCards.Any()); }