Beispiel #1
0
        private void BlackjackDealTransactionTest()
        {
            // arrange
            int           numOfRoundsDealt = 0;
            List <Player> players          = new List <Player>();
            Player        alex             = new Player {
                Name = "Alex"
            };
            Player bill = new Player {
                Name = "Bill"
            };
            Player charlie = new Player {
                Name = "Charlie"
            };

            players.Add(alex);
            players.Add(bill);
            players.Add(charlie);
            BlackjackDeal blackjackDeal = new BlackjackDeal(players, bill);

            // act
            blackjackDeal.Execute();

            // assert
            numOfRoundsDealt++;
            foreach (Player player in players)
            {
                Assert.AreEqual(player.Hand.Size, numOfRoundsDealt);
            }
            Assert.AreEqual(Deck.Instance.Size, Deck.Instance.FullDeckSize - (players.Count * numOfRoundsDealt));

            // act
            blackjackDeal.Execute();

            // assert
            numOfRoundsDealt++;
            foreach (Player player in players)
            {
                Assert.AreEqual(player.Hand.Size, numOfRoundsDealt);
            }
            Assert.AreEqual(Deck.Instance.Size, Deck.Instance.FullDeckSize - (players.Count * numOfRoundsDealt));

            // act
            blackjackDeal.Execute();

            // assert
            numOfRoundsDealt++;
            foreach (Player player in players)
            {
                Assert.AreEqual(player.Hand.Size, numOfRoundsDealt);
            }
            Assert.AreEqual(Deck.Instance.Size, Deck.Instance.FullDeckSize - (players.Count * numOfRoundsDealt));
        }
Beispiel #2
0
        public void BlackjackIdentifyWinnerTransactionTest_BasicDeck()
        {
            // arrange
            List <Player> players = new List <Player>();
            Player        alex    = new Player {
                Name = "Alex"
            };
            Player bill = new Player {
                Name = "Bill"
            };
            Player charlie = new Player {
                Name = "Charlie"
            };

            players.Add(alex);
            players.Add(bill);
            players.Add(charlie);

            Shuffle shuffle = new Shuffle(bill);

            shuffle.Execute();

            BlackjackDeal blackjackDeal = new BlackjackDeal(players, bill);
            Random        rand          = new Random(DateTime.Now.Millisecond);
            int           upperBound    = rand.Next(2, 6);

            // deal anywhere from 2 to 5 cards to each player
            for (int i = 1; i <= upperBound; i++)
            {
                blackjackDeal.Execute();
            }

            IdentifyWinnerBlackjack identWinner = new IdentifyWinnerBlackjack(players);

            // act
            identWinner.Execute();

            // assert
            // verify that the winner(s) has/have the highest score
            Assert.AreEqual(players.Where(p => p.HandStatus == HandStatus.Winner).Select(p => p.Hand.Score).Max(), players.Select(p => p.Hand.Score).Max());
        }
        private void BlackjackDealTransactionTest()
        {
            // arrange
            int numOfRoundsDealt = 0;
            List<Player> players = new List<Player>();
            Player alex = new Player { Name = "Alex" };
            Player bill = new Player { Name = "Bill" };
            Player charlie = new Player { Name = "Charlie" };
            players.Add(alex);
            players.Add(bill);
            players.Add(charlie);
            BlackjackDeal blackjackDeal = new BlackjackDeal(players, bill);

            // act
            blackjackDeal.Execute();

            // assert
            numOfRoundsDealt++;
            foreach (Player player in players)
            {
                Assert.AreEqual(player.Hand.Size, numOfRoundsDealt);
            }
            Assert.AreEqual(Deck.Instance.Size, Deck.Instance.FullDeckSize - (players.Count * numOfRoundsDealt));

            // act
            blackjackDeal.Execute();

            // assert
            numOfRoundsDealt++;
            foreach (Player player in players)
            {
                Assert.AreEqual(player.Hand.Size, numOfRoundsDealt);
            }
            Assert.AreEqual(Deck.Instance.Size, Deck.Instance.FullDeckSize - (players.Count * numOfRoundsDealt));

            // act
            blackjackDeal.Execute();

            // assert
            numOfRoundsDealt++;
            foreach (Player player in players)
            {
                Assert.AreEqual(player.Hand.Size, numOfRoundsDealt);
            }
            Assert.AreEqual(Deck.Instance.Size, Deck.Instance.FullDeckSize - (players.Count * numOfRoundsDealt));
        }
        public void BlackjackIdentifyWinnerTransactionTest_BasicDeck()
        {
            // arrange
            List<Player> players = new List<Player>();
            Player alex = new Player { Name = "Alex" };
            Player bill = new Player { Name = "Bill" };
            Player charlie = new Player { Name = "Charlie" };
            players.Add(alex);
            players.Add(bill);
            players.Add(charlie);

            Shuffle shuffle = new Shuffle(bill);
            shuffle.Execute();

            BlackjackDeal blackjackDeal = new BlackjackDeal(players, bill);
            Random rand = new Random(DateTime.Now.Millisecond);
            int upperBound = rand.Next(2,6);
            // deal anywhere from 2 to 5 cards to each player
            for (int i = 1; i <= upperBound; i++)
            {
                blackjackDeal.Execute();
            }            

            IdentifyWinnerBlackjack identWinner = new IdentifyWinnerBlackjack(players);

            // act
            identWinner.Execute();

            // assert
                // verify that the winner(s) has/have the highest score
            Assert.AreEqual(players.Where(p => p.HandStatus == HandStatus.Winner).Select(p => p.Hand.Score).Max(), players.Select(p => p.Hand.Score).Max());
        }