Esempio n. 1
0
        public void DealShouldReturnNullWhenNoCardsLeftInDeck()
        {
            var deck = new Deck();

            for (int i = 0; i < 52; i++)
            {
                Card? dealt = deck.Deal();
                Assert.That(dealt.HasValue, Is.True);
            }

            var card = deck.Deal();

            Assert.That(card, Is.Null);
        }
Esempio n. 2
0
        public void DealShouldRemoveCardFromDeck()
        {
            var deck = new Deck();

            Card? card = deck.Deal();

            Assert.That( deck.Contains(card.Value), Is.False);
        }
Esempio n. 3
0
        private static void AssertDecksHaveDifferentOrder(Deck first, Deck second)
        {
            int mismatches = 0;
            for (int i = 0; i < 52; i++)
            {
                var cardA = first.Deal().Value;
                var cardB = second.Deal().Value;

                if (!cardA.Equals(cardB))
                    mismatches++;
            }

            Assert.That(mismatches, Is.AtLeast(2));
        }