コード例 #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);
        }
コード例 #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);

            Assert.AreEqual(10, hard17Player.HandValue());
        }
コード例 #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());
        }
コード例 #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());
        }
コード例 #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());
        }
コード例 #6
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.AreEqual(27, hard17Player.HandValue());
        }
コード例 #7
0
        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.AreEqual(21, player.HandValue());
        }
コード例 #8
0
        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.AreEqual(20, human.HandValue());
        }
コード例 #9
0
        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.AreEqual(25, human.HandValue());
        }
コード例 #10
0
        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.AreEqual(12, player.HandValue());
        }
コード例 #11
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);
        }
コード例 #12
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);
        }
コード例 #13
0
        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.AreEqual(16, human.HandValue());
        }
コード例 #14
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);
        }