public void DeckCanReturnAllCards() { // Arrange ICardOrderingProvider cardOrderingProvider = new SuitMajorSortedCardOrderingProvider(); ICardDeck cardDeck = new SnapCardDeck(cardOrderingProvider); // Act for (int i = 0; i < 200; i++) // Add 200 { cardDeck.Add(new SnapCard(Suit.Diamonds, Rank.Five)); } var test = cardDeck.GetAll(); // Assert Assert.IsTrue(test.Count() == 200); }
public void DeckGetAllIsNonDestructive() { // Arrange ICardOrderingProvider cardOrderingProvider = new SuitMajorSortedCardOrderingProvider(); ICardDeck cardDeck = new SnapCardDeck(cardOrderingProvider); // Act for (int i = 0; i < 200; i++) // Add 200 { cardDeck.Add(new SnapCard(Suit.Diamonds, Rank.Five)); } var test = cardDeck.GetAll(); // Assert Assert.IsFalse(cardDeck.IsEmpty); }
public void DeckCanShuffleCards() { // Arrange ICardOrderingProvider cardOrderingProvider = new SuitMajorSortedCardOrderingProvider(); ICardDeck cardDeck = new SnapCardDeck(cardOrderingProvider); // Act // The current implementation of SnapCardDeck gives the impression that the cards are // maintained in a sorted state, this makes validating the suffle tricky... // However this effectively means that taking cards in an order different to that enforced // by the card ordering provider and adding them is the same as shuffling them // So if we add the King, Jack, Queen and Ace of spades and read them out, we should // get the Ace, Jack, Queen and King of spades back. var cards = new List <SnapCard> { new SnapCard(Suit.Spades, Rank.King), new SnapCard(Suit.Spades, Rank.Jack), new SnapCard(Suit.Spades, Rank.Queen), new SnapCard(Suit.Spades, Rank.Ace) }; foreach (var card in cards) { cardDeck.Add(card); } cardDeck.Shuffle(); // Pointless as described above, but will stop code coverage moaning // Assert var expectedResult = new List <SnapCard> { new SnapCard(Suit.Spades, Rank.Ace), new SnapCard(Suit.Spades, Rank.Jack), new SnapCard(Suit.Spades, Rank.Queen), new SnapCard(Suit.Spades, Rank.King) }; var test = cardDeck.GetAll(); Assert.IsTrue(test.SequenceEqual(expectedResult, new SnapCardComparer())); }