public static void ShouldGenerateShoe(int deckCount) { var shoeGenerator = new ShoeGenerator(); var shoe = shoeGenerator.GenerateShoe(deckCount); shoe.Cards.Count.ShouldBe(52 * deckCount); // 52 * how many decks you specify, } // to make sure that the that there are no extra
public static void ShouldShuffle() { var shoeGenerator = new ShoeGenerator(); var shoe = shoeGenerator.GenerateShoe(4); var originalShoe = shoe.Cards.ToList(); shoe.Shuffle(); // count how many clashes, compare the index of shoe and originalShoe int clashes = 0; for (int i = 0; i < shoe.Cards.Count; i++) { var originalRank = originalShoe[i].Rank; var originalSuit = originalShoe[i].Suit; var shuffledRank = shoe.Cards[i].Rank; var shuffledSuit = shoe.Cards[i].Suit; //If original rank and suit is the same as the shuffled rank and suit, add to the clashes variable if (originalRank == shuffledRank && originalSuit == shuffledSuit) { clashes++; } } double clashPercent = (clashes / (double)shoe.Cards.Count) * 100; if (clashPercent >= 10) { Assert.False(true, "Over 10% Clash rate"); } }
public void ResetGameState() { CurrentShoe = new ShoeGenerator().GenerateShoe(4); PlayerHand = new Hand(); PlayerSplitHand = new Hand(); CPUHand = new Hand(); DealerHand = new Hand(); CurrentShoe.Shuffle(); CheckPlayerHasMoney(); }
public static void ShouldOnlyBeDeckCountOfOneCard(int deckCount) { var shoeGenerator = new ShoeGenerator(); var shoe = shoeGenerator.GenerateShoe(deckCount); shoe.Shuffle(); var groups = shoe.Cards.GroupBy(x => new { x.Rank, x.Suit }).ToList(); groups.Count.ShouldBe(52); var cardsPerGroup = groups.Select(x => x.Count()); cardsPerGroup.All(x => x == deckCount).ShouldBeTrue(); }