Ejemplo n.º 1
0
        public void HumanWinsWithBlackJackEnum()
        {
            var dealerCards = new DeckMock(new[]
            {
                new Card(CardFace.Eight, Suit.Hearts),
                new Card(CardFace.Ten, Suit.Diamonds),
            });

            var playerCards = new DeckMock(new[]
            {
                new Card(CardFace.Ace, Suit.Hearts),
                new Card(CardFace.Jack, Suit.Diamonds),
            });
            var playerResponse = new TestResponder(new []
            {
                StayResponse,
            });
            var player       = new Human(playerCards, playerResponse);
            var soft17Player = new Soft17Player(dealerCards);
            var console      = new ConsoleInputOutput();
            var blackjack    = new BlackJack(new List <Player> {
                player
            }, console, soft17Player);

            blackjack.StartGame();

            Assert.AreEqual(GameStatus.BlackJack, player.GameStatus);
        }
Ejemplo n.º 2
0
        public void NumberOfTimesPlayTurnCalledForPlayer()
        {
            var deck      = new Deck();
            var player    = new PlayerSpy(deck, OneHit);
            var dealer    = new Soft17Player(deck);
            var console   = new ConsoleInputOutput();
            var blackjack = new BlackJack(new Player[] { player }, console, dealer);

            blackjack.StartGame();

            Assert.AreEqual(1, player.NumberOfTimesTurnPlayed);
        }
Ejemplo n.º 3
0
        public void StaysOn17()
        {
            var testDeck = new DeckMock(new[]
            {
                new Card(CardFace.Ten, Suit.Hearts),
                new Card(CardFace.Seven, Suit.Spades),
                new Card(CardFace.Jack, Suit.Diamonds),
            });
            var soft17Player = new Soft17Player(testDeck);

            soft17Player.PlayTurn();

            Assert.AreEqual(17, soft17Player.HandValue());
        }
Ejemplo n.º 4
0
        public void StartsWithTwoCards()
        {
            var testDeck = new DeckMock(new[]
            {
                new Card(CardFace.Five, Suit.Hearts),
                new Card(CardFace.Five, Suit.Spades),
                new Card(CardFace.Eight, Suit.Clubs),
            });
            var soft17Player = new Soft17Player(testDeck);

            soft17Player.NewHand();

            Assert.AreEqual(10, soft17Player.HandValue());
        }
Ejemplo n.º 5
0
        public void HitsUnder17()
        {
            var testDeck = new DeckMock(new[]
            {
                new Card(CardFace.Ten, Suit.Hearts),
                new Card(CardFace.Six, Suit.Spades),
                new Card(CardFace.Ten, Suit.Diamonds),
            });
            var soft17Player = new Soft17Player(testDeck);

            soft17Player.PlayTurn();

            Assert.AreEqual(26, soft17Player.HandValue());
        }
Ejemplo n.º 6
0
        public void EachPlayerPlaysTheirTurn()
        {
            var deck = new Deck();

            var player1 = new PlayerSpy(deck, NoHits);
            var player2 = new PlayerSpy(deck, OneHit);

            var dealer    = new Soft17Player(deck);
            var console   = new ConsoleInputOutput();
            var blackjack = new BlackJack(new Player[] { player1, player2 }, console, dealer);

            blackjack.StartGame();

            Assert.NotZero(player1.NumberOfTimesTurnPlayed);
            Assert.NotZero(player2.NumberOfTimesTurnPlayed);
        }
Ejemplo n.º 7
0
        public void HumanHitsAndBusts()
        {
            var player     = PlayerSpy.CreateBustedPlayer();
            var dealerDeck = new DeckMock(new[]
            {
                new Card(CardFace.Jack, Suit.Hearts),
                new Card(CardFace.Eight, Suit.Spades),
            });

            var dealer    = new Soft17Player(dealerDeck);
            var console   = new ConsoleInputOutput();
            var blackjack = new BlackJack(new List <Player> {
                player
            }, console, dealer);

            blackjack.StartGame();

            Assert.AreEqual(GameStatus.Busted, player.GameStatus);
        }
Ejemplo n.º 8
0
        public void DealerWins()
        {
            var player     = PlayerSpy.CreateLosingPlayer();
            var dealerDeck = new DeckMock(new[]
            {
                new Card(CardFace.Eight, Suit.Hearts),
                new Card(CardFace.Ten, Suit.Diamonds),
                new Card(CardFace.Ace, Suit.Hearts),
            });
            var dealer    = new Soft17Player(dealerDeck);
            var console   = new ConsoleInputOutput();
            var blackjack = new BlackJack(new List <Player> {
                player
            }, console, dealer);

            blackjack.StartGame();

            Assert.AreEqual(GameStatus.Won, dealer.GameStatus);
        }
Ejemplo n.º 9
0
        public void DealerBusts()
        {
            var player     = PlayerSpy.CreatePlayerHandValue18();
            var dealerDeck = new DeckMock(new[]
            {
                new Card(CardFace.Jack, Suit.Hearts),
                new Card(CardFace.Six, Suit.Spades),
                new Card(CardFace.Nine, Suit.Diamonds),
            });

            var dealer    = new Soft17Player(dealerDeck);
            var console   = new ConsoleInputOutput();
            var blackjack = new BlackJack(new List <Player> {
                player
            }, console, dealer);

            blackjack.StartGame();

            Assert.AreEqual(GameStatus.Busted, dealer.GameStatus);
        }