Пример #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.Equal(GameStatus.BlackJack, player.GameStatus);
        }
Пример #2
0
        public void StartsWithTwoCards()
        {
            var testDeck = new DeckMock(new[]
            {
                new Card(CardFace.Five, Suit.Hearts),
                new Card(CardFace.Five, Suit.Spades)
            });
            var hard17Player = new Hard17Player(testDeck);

            hard17Player.NewHand();

            Assert.Equal(10, hard17Player.HandValue());
        }
Пример #3
0
        public void HitsOn17()
        {
            var testDeck = new DeckMock(new[]
            {
                new Card(CardFace.Ten, Suit.Hearts),
                new Card(CardFace.Seven, Suit.Spades),
                new Card(CardFace.Jack, Suit.Diamonds),
            });
            var hard17Player = new Hard17Player(testDeck);

            hard17Player.PlayTurn();

            Assert.Equal(27, hard17Player.HandValue());
        }
Пример #4
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.Equal(17, soft17Player.HandValue());
        }
Пример #5
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.Equal(10, soft17Player.HandValue());
        }
Пример #6
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.Equal(26, soft17Player.HandValue());
        }
Пример #7
0
        public void StaysOn20()
        {
            var testDeck = new DeckMock(new[]
            {
                new Card(CardFace.Ten, Suit.Hearts),
                new Card(CardFace.Jack, Suit.Spades),
                new Card(CardFace.Ace, Suit.Diamonds),
                new Card(CardFace.Five, Suit.Diamonds),
            });
            var hard17Player = new Hard17Player(testDeck);

            hard17Player.PlayTurn();

            Assert.Equal(20, hard17Player.HandValue());
        }
        public void AceCanBeEleven()
        {
            var testDeck = new DeckMock(new[]
            {
                new Card(CardFace.Jack, Suit.Clubs),
                new Card(CardFace.Ace, Suit.Diamonds),
            });

            var player = new PlayerImplementation(testDeck);

            player.PlayTurn();
            player.PlayTurn();

            Assert.Equal(21, player.HandValue());
        }
        public void CanStayWithTwoCards()
        {
            var testDeck = new DeckMock(new[]
            {
                new Card(CardFace.Ten, Suit.Clubs),
                new Card(CardFace.Ten, Suit.Diamonds),
                new Card(CardFace.Five, Suit.Clubs),
            });
            var testQuestionResponse = new TestResponder(StayInput); //put in () "0"
            var human = new Human(testDeck, testQuestionResponse);

            human.NewHand();
            human.PlayTurn();

            Assert.Equal(20, human.HandValue());
        }
        public void CanHitAt20()
        {
            var testDeck = new DeckMock(new[]
            {
                new Card(CardFace.Ten, Suit.Clubs),
                new Card(CardFace.Ten, Suit.Diamonds),
                new Card(CardFace.Five, Suit.Clubs),
            });
            var testQuestionResponse = new TestResponder(HitInput);
            var human = new Human(testDeck, testQuestionResponse);

            human.NewHand();
            human.PlayTurn();

            Assert.Equal(25, human.HandValue());
        }
        public void AceChangesValue()
        {
            var testDeck = new DeckMock(new[]
            {
                new Card(CardFace.Ace, Suit.Clubs),
                new Card(CardFace.Ace, Suit.Diamonds),
                new Card(CardFace.Five, Suit.Hearts),
                new Card(CardFace.Five, Suit.Hearts),
            });

            var player = new PlayerImplementation(testDeck);

            player.PlayTurn();
            player.PlayTurn();

            Assert.Equal(12, player.HandValue());
        }
        public void StartsWithTwoCards()
        {
            //Given
            var testDeck = new DeckMock((new []
            {
                new Card(CardFace.Eight, Suit.Clubs),
                new Card(CardFace.Eight, Suit.Diamonds),
                new Card(CardFace.Five, Suit.Clubs),
            }));
            var testQuestionResponse = new TestResponder(StayInput);
            var human = new Human(testDeck, testQuestionResponse);

            human.NewHand();

            //When

            //Then
            Assert.Equal(16, human.HandValue());
        }
Пример #13
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.Equal(GameStatus.Busted, player.GameStatus);
        }
Пример #14
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.Equal(GameStatus.Won, dealer.GameStatus);
        }
Пример #15
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.Equal(GameStatus.Busted, dealer.GameStatus);
        }