public void OperatorsTest() { var deck1 = new DeckOfCards(); var deck2 = new DeckOfCards(); var card1 = deck1.Draw(); var card2 = deck2.Draw(); var card3 = deck1.Draw(); Assert.IsTrue(card1 == card2); Assert.IsTrue(card1 != card3); }
public void DrawTest() { // Draw off the first card var firstCard = _Deck.Draw(); Assert.IsNotNull(firstCard); Console.WriteLine($"Drawn Card has a suit of {firstCard.Suit} and value of {firstCard.Value}"); // Peek the second card var secondCard = _Deck.Peek(); Assert.IsNotNull(secondCard); Console.WriteLine($"Drawn Card has a suit of {secondCard.Suit} and value of {secondCard.Value}"); // Ensure the cards are not equal Assert.AreNotEqual(firstCard, secondCard); }
public void StartRound() { DeckOfCards.Initialize(); foreach (DSeat seat in Seats) { if (seat.SmallBlind) { seat.Bid(SmallBlindAmount); } if (seat.BigBlind) { seat.Bid(BigBlindAmount); } } GetTurnOrder(); foreach (DSeat seat in SeatsInTurnOrder) { seat.NewRound(); } for (int i = 0; i < 2; i++) { foreach (DSeat seat in SeatsInTurnOrder) { seat.Pocket.Add(DeckOfCards.Draw()); } } }
public void UniqueCardsTest() { var deck = new DeckOfCards(); var uniques = new HashSet <Card>(); var card = deck.Draw(); deck.Shuffle(); // Loop through the entire deck and add the cards to // a HashSet (which only takes unique items) while (card != null) { uniques.Add(card); card = deck.Draw(); } Assert.AreEqual(expected: 52, actual: uniques.Count); }
public void PeekTest() { var deck = new DeckOfCards(); deck.Shuffle(); var expected = deck.Peek(); var actual = deck.Draw(); Assert.AreEqual(expected, actual); }
private void DrawEvent(object sender, RoutedEventArgs e) { List <Card> drawnCards = _deck.Draw(int.Parse(NumCards.Text == "" ? "0" : NumCards.Text)); if (drawnCards is null) { MessageField.Content = _deck.ErrorMessage; return; } DisplayCards(drawnCards); MessageField.Content = $"Drew {drawnCards.Count} cards, {_deck.CardsRemaining} cards remaining."; }
public void ReturnCardTest() { var deck = new DeckOfCards(); deck.Shuffle(); // Draw a card and then return it to the bottom // of the deck var expected = deck.Draw(); var result = deck.ReturnCard(expected); var actual = deck[52]; Assert.IsTrue(result); // Make sure the same card is at place 52 Assert.AreEqual(expected, actual); // Make sure you cant return an already existing card // to the deck expected = deck[26]; result = deck.ReturnCard(expected); actual = deck[52]; Assert.IsFalse(result); Assert.AreNotEqual(expected, actual); }