public void AddDeckCardsToPile(ShitheadGameConfig config, Pile pile, CreateDeckOptions options) { var cards = new List <Card>(); for (var i = 1; i <= 13; i++) { cards.Add(new Card(pile, CardSuit.Clubs, i)); cards.Add(new Card(pile, CardSuit.Diamonds, i)); cards.Add(new Card(pile, CardSuit.Hearts, i)); cards.Add(new Card(pile, CardSuit.Spades, i)); } if (options.IncludeJokers) { for (var i = 0; i < 2; i++) { cards.Add(new Card(pile, CardSuit.Joker, config.Joker)); } } if (options.Shuffled) { _shuffler.Shuffle(cards); } foreach (var card in cards) { pile.Cards.Add(card); } }
public void CreateDeck_Card_count_ExpectedBehavior(bool includeJokers, int expectedCardCount) { // Arrange var options = new CreateDeckOptions { IncludeJokers = includeJokers, }; var pile = new Pile(null, PileType.Deck, "test-pile"); // Act _factory.AddDeckCardsToPile(ShitheadGameConfig.Default, pile, options); // Assert Assert.Equal(expectedCardCount, pile.Cards.Count); }
public void CreateDeck_Shuffle_called_when_expected(bool shuffle) { // Arrange var options = new CreateDeckOptions { Shuffled = shuffle }; var pile = new Pile(null, PileType.Deck, "test-pile"); // Act _factory.AddDeckCardsToPile(ShitheadGameConfig.Default, pile, options); // Assert if (shuffle) { _shuffler.ReceivedWithAnyArgs(1).Shuffle <Card>(null); } else { _shuffler.DidNotReceiveWithAnyArgs().Shuffle <Card>(null); } }