public void NewGameBlackJacDraw() { var dealerCards = GenerateCards(new int[] { 0, 9 }).ToList(); var guestCards = GenerateCards(new int[] { 0, 11 }).ToList(); var game = new GameFlow(new TestRandomEngine(dealerCards, guestCards)); var data = game.Initialize(); Assert.IsNull(data.Winner, "There should not be a winner"); Assert.IsTrue(data.DealerCards.All(card => !card.Hidden), "Dealer must face up its hidden card"); Assert.IsTrue(data.GameOver, "The game is over"); Assert.AreEqual <int>(21, data.CurrentDealerScore, "Dealer score should be 21 considering that the game is over"); Assert.AreEqual <int>(21, data.CurrentGuestScore, "Guest score should be 21"); }
public void NewGameBlackJackDealer() { var dealerCards = GenerateCards(new int[] { 0, 12 }).ToList(); var guestCards = GenerateCards(new int[] { 1, 9 }).ToList(); var game = new GameFlow(new TestRandomEngine(dealerCards, guestCards)); var data = game.Initialize(); Assert.IsNotNull(data.Winner, "There should be a winner"); Assert.AreEqual <Player?>(Player.Dealer, data.Winner.Value, "The winner should be the Dealer"); Assert.IsTrue(data.DealerCards.All(card => !card.Hidden), "Dealer must face up its hidden card"); Assert.IsTrue(data.GameOver, "The game is over"); Assert.AreEqual <int>(21, data.CurrentDealerScore, "Dealer score should be 21 considering that all cards are visible"); Assert.AreEqual <int>(20, data.CurrentGuestScore, "Guest score should be 20"); }
public void NewGameNoWinner() { var dealerCards = GenerateCards(new int[] { 1, 4 }).ToList(); var guestCards = GenerateCards(new int[] { 1, 6 }).ToList(); var game = new GameFlow(new TestRandomEngine(dealerCards, guestCards)); var data = game.Initialize(); Assert.IsNotNull(game, "Should not be null"); Assert.AreEqual <int>(2, data.DealerCards.Count, "Dealer should start with 2 cards"); Assert.AreEqual <int>(1, data.DealerCards.Count(card => card.Hidden), "Dealer should start exacly with 1 hidden card"); Assert.AreEqual <int>(2, data.GuestCards.Count, "Guest should start with 2 cards"); Assert.IsTrue(data.GuestCards.All(card => !card.Hidden), "Guest should start with all its cards faced up"); Assert.IsNull(data.Winner, "There should be no winner at the begining"); Assert.AreEqual <int>(5, data.CurrentDealerScore, "Dealer score should be 5, wich is the only one visible card"); Assert.AreEqual <int>(9, data.CurrentGuestScore, "Guest score should be 9"); }
public void DealerLosesAfterStandBelow21() { var dealerCards = GenerateCards(new int[] { 3, 5 }).ToList(); var guestCards = GenerateCards(new int[] { 12, 9 }).ToList(); var randomIndexes = new int[] { 0, 0, 0 }; var mockCards = GenerateCards(randomIndexes).ToList(); var game = new GameFlow(new TestRandomEngine(dealerCards, guestCards, mockCards)); var data = game.Initialize(); game.Stand(data); Assert.IsTrue(data.GameOver, "The game is over"); Assert.IsTrue(data.DealerCards.Count <= 5, "Dealer should not have more than 5 cards"); Assert.AreEqual <Player?>(Player.Guest, data.Winner.Value, "The winner should be the Guest"); Assert.AreEqual <int>(13, data.CurrentDealerScore, "Dealer score should be 13 considering that the game is over"); Assert.AreEqual <int>(20, data.CurrentGuestScore, "Guest score should be 20"); }
public void GuestHitWins() { var dealerCards = GenerateCards(new int[] { 4, 6 }).ToList(); var guestCards = GenerateCards(new int[] { 3, 5 }).ToList(); var randomIndexes = new int[] { 0, 0, 8 }; var mockCards = GenerateCards(randomIndexes).ToList(); var game = new GameFlow(new TestRandomEngine(dealerCards, guestCards, mockCards)); var data = game.Initialize(); foreach (var item in randomIndexes) { game.Hit(data); } Assert.IsNotNull(data.Winner, "There should be a winner"); Assert.AreEqual <Player?>(Player.Guest, data.Winner.Value, "The winner should be the Guest"); Assert.IsTrue(data.GameOver, "The game is over"); Assert.AreEqual <int>(12, data.CurrentDealerScore, "Dealer score should be 12 considering that the game is over"); Assert.AreEqual <int>(21, data.CurrentGuestScore, "Guest score should be 21"); }