public void play_a_simulated_game_player_wins() { //Dependencies.randomSeeds.ConstantValue = 1234; Dependencies.randomInstance.ConstantValue = new Random(1234); mockConsoleIO.LoadReadValue("S"); BlackjackGame game = new BlackjackGame(); string playerName = "Billy Joel"; Dealer dealer = new Dealer(); IPlayer player = new HumanPlayer(playerName); IDeck deck = BlackjackOperations.GetAndShuffleNewDeck(); game.play(deck, dealer, player); int i = 0; Assert.AreEqual($"Player {playerName}, Score=18", mockConsoleIO.GetConsoleWrites()[i++]); Assert.AreEqual($"Eight of Hearts,Queen of Hearts", mockConsoleIO.GetConsoleWrites()[i++]); Assert.AreEqual($"Dealer Score Showing=4", mockConsoleIO.GetConsoleWrites()[i++]); Assert.AreEqual($"{Hand.FACEDOWN},Four of Clubs", mockConsoleIO.GetConsoleWrites()[i++]); Assert.AreEqual($"Enter Action H)it, S)tand, B)ust:", mockConsoleIO.GetConsoleWrites()[i++]); Assert.AreEqual($"Player {playerName} Action=Stand", mockConsoleIO.GetConsoleWrites()[i++]); Assert.AreEqual($"Dealer Action=Hit", mockConsoleIO.GetConsoleWrites()[i++]); Assert.AreEqual($"{Hand.FACEDOWN},Four of Clubs,Two of Spades", mockConsoleIO.GetConsoleWrites()[i++]); Assert.AreEqual($"Dealer Action=Hit", mockConsoleIO.GetConsoleWrites()[i++]); Assert.AreEqual($"{Hand.FACEDOWN},Four of Clubs,Two of Spades,Ace of Diamonds", mockConsoleIO.GetConsoleWrites()[i++]); Assert.AreEqual($"Dealer Action=Hit", mockConsoleIO.GetConsoleWrites()[i++]); Assert.AreEqual($"Dealer Action=Busted", mockConsoleIO.GetConsoleWrites()[i++]); Assert.AreEqual($"{Hand.FACEDOWN},Four of Clubs,Two of Spades,Ace of Diamonds,Six of Spades", mockConsoleIO.GetConsoleWrites()[i++]); Assert.AreEqual($"{playerName} wins!", mockConsoleIO.GetConsoleWrites()[i++]); Assert.AreEqual($"Player {playerName}, Score=18", mockConsoleIO.GetConsoleWrites()[i++]); Assert.AreEqual($"Eight of Hearts,Queen of Hearts", mockConsoleIO.GetConsoleWrites()[i++]); Assert.AreEqual($"Dealer Score Showing=23", mockConsoleIO.GetConsoleWrites()[i++]); Assert.AreEqual($"Ten of Hearts,Four of Clubs,Two of Spades,Ace of Diamonds,Six of Spades", mockConsoleIO.GetConsoleWrites()[i++]); Dependencies.consoleIO.reset(); //Dependencies.randomSeeds.reset(); Dependencies.randomInstance.reset(); }
public void parse_action_valid_single_char_typed_lowercase_custom() { Dependencies.consoleIO.ConstantValue = mockConsoleIO; mockConsoleIO.ResetConsole(); mockConsoleIO.LoadReadValue("h"); mockConsoleIO.LoadReadValue("s"); mockConsoleIO.LoadReadValue("b"); IPlayer player = new HumanPlayer(); PlayerAction action = player.NextAction(null); Assert.AreEqual(PlayerAction.Hit, action); action = player.NextAction(null); Assert.AreEqual(PlayerAction.Stand, action); action = player.NextAction(null); Assert.AreEqual(PlayerAction.Busted, action); Assert.AreEqual(3, mockConsoleIO.GetConsoleWrites().Count); Dependencies.consoleIO.reset(); }