コード例 #1
0
        public void TestBlackjackHand()
        {
            Card jackOfClubs   = new Card(SuitEnum.Clubs, SymbolEnum.Jack);
            Card aceOfSpades   = new Card(SuitEnum.Spades, SymbolEnum.Ace);
            Card aceOfHearts   = new Card(SuitEnum.Hearts, SymbolEnum.Ace);
            Card eightOfHearts = new Card(SuitEnum.Hearts, SymbolEnum.Eight);
            Card nineOfHearts  = new Card(SuitEnum.Hearts, SymbolEnum.Nine);

            BlackjackHand hand =
                new BlackjackHand(new Card[] { jackOfClubs, aceOfSpades, eightOfHearts });

            Assert.IsTrue(
                hand.Cards.Count == 3,
                "Should be 3 cards.");

            BlackjackHand hand2 =
                new BlackjackHand(new Card[] { jackOfClubs, aceOfSpades, eightOfHearts });

            Assert.IsTrue(
                hand.Equals(hand2),
                "Hands are equal.");

            hand2 = new BlackjackHand(new Card[] { jackOfClubs, aceOfSpades, nineOfHearts });

            Assert.IsTrue(
                false == hand.Equals(hand2),
                "Hands are not equal.");

            Assert.IsTrue(
                hand.Value == 19,
                "Blackjack hand value is 19");

            hand = new BlackjackHand(new Card[] { jackOfClubs, aceOfSpades, eightOfHearts, aceOfHearts });
            Assert.IsTrue(
                hand.Value == 20,
                "Blackjack hand value is 20");


            TestContext.WriteLine(hand.ToString());
        }