public void AddCard_ValidCardProvided_SuccessCardAddedCardToHand() { // Arrange var deck = new DeckOfCards(true); var cardHand = new CardHand(); // Act cardHand.AddCard(deck.GetCard(new GetRandomCardStrategy())); // Assert Assert.AreEqual(1, cardHand.Count); }
public void GetCard_GetRandomCardStrategy_SuccessRandomCardReturnedAndMarkedAsPlayed() { // Arrange var deck = new DeckOfCards(true); // Act var newCard = deck.GetCard(new GetRandomCardStrategy()); // Assert Assert.IsNotNull(newCard); Assert.IsTrue(newCard.HasBeenPlayed); Assert.AreEqual(51, deck.Cards.Count); }
public void HandRank_Valid4CardHandProvided_SuccessSumOfCardRanksReturned() { // Arrange var deck = new DeckOfCards(); var hand = new CardHand(); for (var cardIndex = 0; cardIndex < 4; cardIndex++) { // Note: In an unshuffled deck, the 1st four cards are all deuces hand.AddCard(deck.GetCard(new GetNextCardStrategy())); } // Act var rank = hand.HandRank; // Assert Assert.AreEqual(4, hand.Count); Assert.AreEqual(8, rank); }
public void GetCard_ZeroCardsRemainingInDeck_FailureReturnsNull() { // Arrange var deck = new DeckOfCards(true); Card newCard; // Act for (int i = 0; i < 52; i++) { newCard = deck.GetCard(new GetNextCardStrategy()); } newCard = deck.GetCard(new GetNextCardStrategy()); // Assert Assert.AreEqual(0, deck.Cards.Count); Assert.IsNull(newCard); }
public void RemoveCard_ValidCardProvided_SuccessCardRemovedCardFromHand() { // Arrange const int numCards = 4; Card addedCard = null; var deck = new DeckOfCards(true); var cardHand = new CardHand(); for (var i = 0; i < numCards; i++) { addedCard = cardHand.AddCard(deck.GetCard(new GetNextCardStrategy())); } // Act var removedCard = cardHand.RemoveCard(addedCard); // Assert Assert.IsNotNull(removedCard); Assert.AreEqual(numCards - 1, cardHand.Count); }