Пример #1
0
        public void TestRankHand()
        {
            // Test an example of each of the 9 ranks we expcect for this game
            // Noting that rank 0 is not possible in this game (because the Joker is dead! R.I.P Heath Ledger!
            //structure of this test case is...
            // create a collection of hands w/ expected rannk
            // loop through collection, cal RankHand() and compare actual vs expected
            // fail the test when the first expected is NOT equal to the actual result

            IPokerRules         pr        = new FiveCardDrawPokerRules();
            List <RankTestHand> testCases = CreateRankTestHands();

            foreach (RankTestHand h in testCases)
            {
                Assert.AreEqual(h.rank, pr.RankHand(h.hand));
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            // Two Simple Demos for Assignment 2
            Random rand = new Random();

            // 1. Deal one hand, print the rank and names of the hand.
            FiveCardDrawPokerRules pr   = new FiveCardDrawPokerRules();
            AceHighPokerDeck       deck = new AceHighPokerDeck(rand);

            deck.Shuffle();
            IHand h1 = pr.DealHand(deck);

            Console.WriteLine("Demo 1...");
            Console.WriteLine("Rank = " + pr.RankHand(h1));
            //Console.WriteLine("Name = " + pr.NameHand(h1));
            // 2. Deal two hands print the rank and names of the hands, compare and print who wins.
        }
Пример #3
0
        public void TestCompareHand()
        {
            // DealHand should return a pokerHand Instance with the first 5 cards from the deck;
            IPokerRules pr = new FiveCardDrawPokerRules();
            IHand       h  = pr.DealHand(new TestDeck());

            Assert.AreEqual(h.Count, 5); // 5 because it;s 5-card draw!
            Assert.IsInstanceOfType(h, typeof(PokerHand));
            int i = 2;

            foreach (ICard c in h)
            {
                Assert.AreEqual(c.Suit, CardSuit.Club);
                Assert.AreEqual(c.Face, i);
                i++;
            }
            Assert.AreEqual(i, 7); // The last card shoild be a 6
        }