public void PlayerLosesTheRoundAfterExceedingTwentyOne() { //Arrange while (_blackjackGameRound.PlayersSumOfCards[EPlayers.Player1] < 21) { _blackjackGameRound.PlayerCall(EPlayers.Player1, ERoundCalls.Hit); } //Act int playerOneSumOfCards = _blackjackGameRound.PlayersSumOfCards[EPlayers.Player1]; ERoundResult playerOneRoundResult = _blackjackGameRound.PlayerResults[EPlayers.Player1]; //Assert if (playerOneSumOfCards <= 21) { string errorMessage = $"Player one is excepted to have a card collection where the sum of card values exceed 21! Actual sum of player one's cards is: {playerOneSumOfCards}"; Assert.Fail(errorMessage); } if (playerOneRoundResult != ERoundResult.DealerWins) { string errorMessage = $"Player one is excepted to have the round result {ERoundResult.DealerWins}! Actual round result of player one is: {playerOneRoundResult}"; Assert.Fail(errorMessage); } }
/// <summary> /// Add the player result of the game round /// </summary> /// <param name="roundNumber">Identifier of the round in the game</param> /// <param name="roundResult">Result of the round for the player</param> public void AddRoundResult(int roundNumber, ERoundResult roundResult) { if (_roundResults.ContainsKey(roundNumber)) { throw new InvalidOperationException("Round result has been already entered for the same round number! It is not allowed to use the same round number identifier for different rounds!"); } _roundResults.Add(roundNumber, roundResult); }