Ejemplo n.º 1
0
        public void bet_lose_amount_returns_amount_of_bet()
        {
            // Arrange
            IBlackjackBet bet = new AnteBet(100);

            // Act
            bet.LoseAmount().Should().Equal(100.0);
        }
Ejemplo n.º 2
0
        public void non_blackjack_win_returns_straight_bet()
        {
            // Arrange
            IBlackjackBet bet = new AnteBet(100);

            // Act
            bet.WinAmount().Should().Equal(100.0);
        }
Ejemplo n.º 3
0
        public void convert_to_push_bet_returns_a_new_push_bet()
        {
            // Arrange
            IBlackjackBet bet = new AnteBet(100);

            // Act
            IBlackjackBet pushBet = bet.ConvertToPushBet();

            // Assert
            pushBet.Should().Not.Be.Null();
            pushBet.Should().Be.OfType<PushBet>();
            pushBet.Amount.Should().Equal(0.0);
        }
Ejemplo n.º 4
0
        public void offer_to_double_down_on_eligible_hand_decreases_players_balance()
        {
            // Arrange
            var player = new BlackjackPlayer {Balance = 100.0};
            var bet = new AnteBet(20.0);

            var dealerFaceUpCard = Substitute.For<IBlackjackCard>();

            var hand1 = Substitute.For<IPlayerHand>();
            hand1.EligibleForDoubleDown.Returns(true);
            hand1.Bet = bet;

            // Act
            player.OfferDoubleDown(hand1, dealerFaceUpCard);

            // Assert
            player.Balance.Should().Equal(80.0);
        }
Ejemplo n.º 5
0
        public void settle_bet_with_equal_hands_returns_zero()
        {
            // Arrange
            IBlackjackBet bet = new AnteBet(100);
            IBlackjackPlayer player = new BlackjackPlayer { Balance = 900 };

            var dealerHand = Substitute.For<IDealerHand>();
            var playerHand = Substitute.For<IPlayerHand>();
            playerHand.Busted.Returns(false);
            dealerHand.Busted.Returns(false);
            playerHand.Value().Returns(20);
            dealerHand.Value().Returns(20);

            playerHand.Bet.Returns(bet);

            // Act
            var amount = player.SettleBet(playerHand, dealerHand);

            // Assert
            amount.Should().Equal(0.0);
        }
Ejemplo n.º 6
0
        public void settle_bet_with_equal_hands_changes_bet_to_push_bet()
        {
            // Arrange
            IBlackjackBet bet = new AnteBet(100);
            IBlackjackPlayer player = new BlackjackPlayer { Balance = 900 };

            var dealerHand = Substitute.For<IDealerHand>();
            var playerHand = Substitute.For<IPlayerHand>();
            playerHand.Busted.Returns(false);
            dealerHand.Busted.Returns(false);
            playerHand.Value().Returns(20);
            dealerHand.Value().Returns(20);

            playerHand.Bet.Returns(bet);

            // Act
            player.SettleBet(playerHand, dealerHand);

            // Assert
            playerHand.Bet.Should().Be.OfType<PushBet>();
        }
Ejemplo n.º 7
0
        public void settle_bet_when_only_dealer_busted_returns_negative_win_amount()
        {
            // Arrange
            IBlackjackPlayer player = new BlackjackPlayer();
            IBlackjackBet bet = new AnteBet(100);

            var dealerHand = Substitute.For<IDealerHand>();
            var playerHand = Substitute.For<IPlayerHand>();
            playerHand.Busted.Returns(false);
            dealerHand.Busted.Returns(true);

            playerHand.Bet.Returns(bet);

            // Act
            var amount = player.SettleBet(playerHand, dealerHand);

            // Assert
            amount.Should().Equal(-100.0);
        }
Ejemplo n.º 8
0
        public void settle_bet_when_only_dealer_busted_credits_players_balance()
        {
            // Arrange
            IBlackjackBet bet = new AnteBet(100);
            IBlackjackPlayer player = new BlackjackPlayer {Balance = 900};

            var dealerHand = Substitute.For<IDealerHand>();
            var playerHand = Substitute.For<IPlayerHand>();
            playerHand.Busted.Returns(false);
            dealerHand.Busted.Returns(true);

            playerHand.Bet.Returns(bet);

            // Act
            player.SettleBet(playerHand, dealerHand);

            // Assert
            player.Balance.Should().Equal(1100.0);
        }
Ejemplo n.º 9
0
        public void offer_to_double_down_on_eligible_hand_doubles_amount_of_bet()
        {
            // Arrange
            var player = new BlackjackPlayer { Balance = 100.0 };
            var bet = new AnteBet(20.0);

            var dealerFaceUpCard = Substitute.For<IBlackjackCard>();

            var hand1 = Substitute.For<IPlayerHand>();
            hand1.EligibleForDoubleDown.Returns(true);
            hand1.Bet = bet;

            // Act
            player.OfferDoubleDown(hand1, dealerFaceUpCard);

            // Assert
            hand1.Bet.Amount.Should().Equal(40.0);
            hand1.Bet.Should().Be.OfType<DoubleDownBet>();
        }