public void Clone_HandHistoryHandWithThreePlayers_ShouldReturnExactHand() { HandHistory script = new HandHistory(); var mock = new Mock<OmahaPlayer>(); mock.Setup(p => p.Act()).Returns(PokerAction.CreateCallAction()); script.ButtonSeat = 0; script.SmallBlindSeat = 1; script.SmallBlindAmount = 5; script.BigBlindSeat = 2; script.BigBlindAmount = 10; script.Players[0] = new HandHistoryPlayer("Bob", 2300); script.Players[1] = new HandHistoryPlayer("Kevin", 2800); script.Players[2] = new HandHistoryPlayer("Burger", 2800); script.Players[0].HoleCards = new Card[] { new Card("5s"), new Card("Js"), new Card("7h"), new Card("Qs") }; script.Players[1].HoleCards = new Card[] { new Card("3s"), new Card("3d"), new Card("7d"), new Card("Ah") }; script.Players[2].HoleCards = new Card[] { new Card("2s"), new Card("Jh"), new Card("3h"), new Card("Ad") }; script.Actions.Add(new HandHistoryPokerAction(script.Players[0], PokerAction.CreateCallAction())); script.Actions.Add(new HandHistoryPokerAction(script.Players[1], PokerAction.CreateCallAction())); script.Actions.Add(new HandHistoryPokerAction(script.Players[2], PokerAction.CreateCallAction())); OmahaHiLoHand hand = new OmahaHiLoHand(script); OmahaHiLoHand cloned = (OmahaHiLoHand)hand.Clone(); HandResult hr1 = hand.RunToEnd(); HandResult hr2 = cloned.RunToEnd(); // This isn't perfect, but for now this is fine Assert.AreEqual(hr1.Winners[0].Player.HoleCards, hr2.Winners[0].Player.HoleCards); }
public void Clone_SingleHandWithSeed_ShouldReturnExactHand() { OmahaHiLoHand hand = new OmahaHiLoHand(); hand.Seed = 1; var mock1 = new Mock<OmahaPlayer>(); mock1.Setup(p => p.Act()).Returns(PokerAction.CreateCallAction()); var mock2 = new Mock<OmahaPlayer>(); mock2.Setup(p => p.Act()).Returns(PokerAction.CreateCallAction()); hand.Sit(mock1.Object, 3, 1000); hand.Sit(mock2.Object, 4, 1000); OmahaHiLoHand cloned = (OmahaHiLoHand)hand.Clone(); HandResult hr1 = hand.RunToEnd(); HandResult hr2 = cloned.RunToEnd(); Assert.AreEqual(hr1.Winners[0].Player.HoleCards, hr2.Winners[0].Player.HoleCards); }
public void RunToEnd_Player1HasHighAndLowPlayer2HasLow_Player1ShouldHave3TimesWinningAmoutAsPlayer2() { HandHistory script = new HandHistory(); var mock1 = new Mock<OmahaPlayer>(); var mock2 = new Mock<OmahaPlayer>(); mock1.Setup(p => p.Act()).Returns(PokerAction.CreateCallAction()); mock1.Setup(p => p.WinEvent(0, 300)).Verifiable(); mock1.Setup(p => p.WinEvent(1, 100)).Verifiable(); mock2.Setup(p => p.Act()).Returns(PokerAction.CreateCallAction()); mock2.Setup(p => p.WinEvent(0, 300)).Verifiable(); mock2.Setup(p => p.WinEvent(1, 100)).Verifiable(); script.ButtonSeat = 0; script.SmallBlindSeat = 1; script.SmallBlindAmount = 100; script.BigBlindSeat = 0; script.BigBlindAmount = 200; script.Players[0] = new HandHistoryPlayer("John", 1000, mock1.Object); script.Players[1] = new HandHistoryPlayer("Bill", 1000, mock2.Object); script.Players[0].HoleCards = CardHelper.CreateHandFromString("4s 5s 6h 7h"); //// Straight flush! script.Players[1].HoleCards = CardHelper.CreateHandFromString("4h 5d 6h 7h"); script.FlopCards = CardHelper.CreateHandFromString("As 2s 3s"); script.TurnCard = new Card(HoldemHand.Hand.Rank8, 0); script.RiverCard = new Card(HoldemHand.Hand.Rank9, 0); OmahaHiLoHand hand = new OmahaHiLoHand(script); HandResult hr = hand.RunToEnd(); mock1.Verify(); mock2.Verify(); }
public void RunToEnd_TwoPlayers_PlayerShouldReceiveWinEvent() { OmahaHiLoHand hand = new OmahaHiLoHand(); var mock1 = new Mock<OmahaPlayer>(); var mock2 = new Mock<OmahaPlayer>(); mock1.Setup(p => p.Act()).Returns(PokerAction.CreateCallAction()).Verifiable(); mock1.Setup(p => p.WinEvent(0, It.Is<long>(w => w > 0))).Verifiable(); mock2.Setup(p => p.Act()).Returns(PokerAction.CreateFoldAction()).Verifiable(); mock2.Setup(p => p.WinEvent(0, It.Is<long>(w => w > 0))).Verifiable(); hand.Sit(mock1.Object, 0, 1000); hand.Sit(mock2.Object, 1, 1000); hand.RunToEnd(); mock1.Verify(); mock2.Verify(); }
public void RunToEnd_TwoPlayers_PlayerShouldReceiveShowdownEvent() { OmahaHiLoHand hand = new OmahaHiLoHand(); var mock1 = new Mock<OmahaPlayer>(); var mock2 = new Mock<OmahaPlayer>(); mock1.Setup(p => p.Act()).Returns(PokerAction.CreateCallAction()).Verifiable(); mock1.Setup(p => p.ShowdownEvent(0, It.Is<Card[]>(c => IsValidHand(c)))).Verifiable(); mock1.Setup(p => p.ShowdownEvent(1, It.Is<Card[]>(c => IsValidHand(c)))).Verifiable(); mock2.Setup(p => p.Act()).Returns(PokerAction.CreateCallAction()).Verifiable(); mock2.Setup(p => p.ShowdownEvent(0, It.Is<Card[]>(c => IsValidHand(c)))).Verifiable(); mock2.Setup(p => p.ShowdownEvent(1, It.Is<Card[]>(c => IsValidHand(c)))).Verifiable(); hand.Sit(mock1.Object, 0, 1000); hand.Sit(mock2.Object, 1, 1000); hand.RunToEnd(); mock1.Verify(); mock2.Verify(); }
public void RunToEnd_TwoPlayers_PlayerShouldReceiveRoundChanged() { OmahaHiLoHand hand = new OmahaHiLoHand(); var mock1 = new Mock<OmahaPlayer>(); var mock2 = new Mock<OmahaPlayer>(); mock1.Setup(p => p.Act()).Returns(PokerAction.CreateCallAction()).Verifiable(); mock1.Setup(p => p.RoundChanged(1)).Verifiable(); mock1.Setup(p => p.RoundChanged(2)).Verifiable(); mock1.Setup(p => p.RoundChanged(3)).Verifiable(); mock2.Setup(p => p.Act()).Returns(PokerAction.CreateCallAction()).Verifiable(); mock2.Setup(p => p.RoundChanged(1)).Verifiable(); mock2.Setup(p => p.RoundChanged(2)).Verifiable(); mock2.Setup(p => p.RoundChanged(3)).Verifiable(); hand.Sit(mock1.Object, 0, 1000); hand.Sit(mock2.Object, 1, 1000); hand.RunToEnd(); mock1.Verify(); mock2.Verify(); }
public void RunToEnd_TwoPlayers_PlayerShouldReceiveGameInfoWithTwoPlayers() { OmahaHiLoHand hand = new OmahaHiLoHand(); var mock1 = new Mock<OmahaPlayer>(); var mock2 = new Mock<OmahaPlayer>(); mock1.Setup(p => p.Act()).Returns(PokerAction.CreateCallAction()).Verifiable(); mock1.Setup(p => p.GameStartEvent(It.Is<IGameInfo>(g => g.NumberOfLivePlayersHand == 2))).Verifiable(); mock2.Setup(p => p.Act()).Returns(PokerAction.CreateCallAction()).Verifiable(); mock2.Setup(p => p.GameStartEvent(It.Is<IGameInfo>(g => g.NumberOfLivePlayersHand == 2))).Verifiable(); hand.Sit(mock1.Object, 0, 1000); hand.Sit(mock2.Object, 1, 1000); hand.RunToEnd(); mock1.Verify(); mock2.Verify(); }
public void RunToEnd_TwoPlayers_CanDeclareWinner() { OmahaHiLoHand hand = new OmahaHiLoHand(); int numPlayers = 2; OmahaPlayer[] players = new OmahaPlayer[2]; for (int i = 0; i < numPlayers; i++) { var mock = new Mock<OmahaPlayer>(); mock.Setup(p => p.Act()).Returns(PokerAction.CreateCallAction()).Verifiable(); players[i] = mock.Object; hand.Sit(mock.Object, i, 1000); } HandResult result = hand.RunToEnd(); Assert.GreaterOrEqual(result.Winners.Count, 1); }
public void RunToEnd_TwoPlayersRaisePlayerAndFoldPlayer_VerifyRaisePlayerIsWinner() { OmahaHiLoHand hand = new OmahaHiLoHand(); long amountToBet = 1000; var raise = new Mock<OmahaPlayer>(); var fold = new Mock<OmahaPlayer>(); raise.Setup(p => p.Act()).Returns(PokerAction.CreateRaiseAction(amountToBet)).Callback(() => amountToBet += 1000).Verifiable(); fold.Setup(p => p.Act()).Returns(PokerAction.CreateFoldAction()).Verifiable(); hand.Sit(raise.Object, 0, 1000); hand.Sit(fold.Object, 1, 1000); HandResult result = hand.RunToEnd(); Assert.AreEqual(1, result.Winners.Count); Assert.AreEqual(raise.Object, result.Winners[0].Player); }
public void RunToEnd_TwoPlayersCallPlayerAndFoldPlayer_VerifyCallPlayerIsWinner() { OmahaHiLoHand hand = new OmahaHiLoHand(); var call = new Mock<OmahaPlayer>(); var fold = new Mock<OmahaPlayer>(); call.Setup(p => p.Act()).Returns(PokerAction.CreateCallAction()).Verifiable(); fold.Setup(p => p.Act()).Returns(PokerAction.CreateFoldAction()).Verifiable(); hand.Sit(call.Object, 0, 1000); hand.Sit(fold.Object, 1, 1000); HandResult result = hand.RunToEnd(); Assert.AreEqual(1, result.Winners.Count); Assert.AreEqual(call.Object, result.Winners[0].Player); call.Verify(); fold.Verify(); }
public void RunToEnd_ThreeCallPlayers_RunThreeHands() { OmahaHiLoHand hand = new OmahaHiLoHand(); int numPlayers = 3; OmahaPlayer[] players = new OmahaPlayer[numPlayers]; for (int i = 0; i < numPlayers; i++) { var mock = new Mock<OmahaPlayer>(); mock.Setup(p => p.Act()).Returns(PokerAction.CreateCallAction()); players[i] = mock.Object; hand.Sit(mock.Object, i, 1000); } List<HandResult> results = new List<HandResult>(); for (int i = 0; i < 3; i++) { HandResult result = hand.RunToEnd(); Assert.IsFalse(results.Contains(result)); results.Add(result); } }
public void RunToEnd_SetupHandHistoryScript_MockPlayerShouldNeverBeCalled() { HandHistory script = new HandHistory(); var mock = new Mock<OmahaPlayer>(); mock.Setup(p => p.Act()).Returns(PokerAction.CreateCallAction()); script.ButtonSeat = 0; script.SmallBlindSeat = 1; script.SmallBlindAmount = 5; script.BigBlindSeat = 2; script.BigBlindAmount = 10; script.Players[0] = new HandHistoryPlayer("John", 2300); script.Players[1] = new HandHistoryPlayer("Billy", 2800); script.Players[2] = new HandHistoryPlayer("Roger", 3000, mock.Object); script.Players[5] = new HandHistoryPlayer("Nick", 1000); script.Players[2].HoleCards = new Card[] { new Card("5s"), new Card("Js"), new Card("5h"), new Card("Qs") }; script.Actions.Add(new HandHistoryPokerAction(script.Players[5], PokerAction.CreateFoldAction())); script.Actions.Add(new HandHistoryPokerAction(script.Players[0], PokerAction.CreateFoldAction())); script.Actions.Add(new HandHistoryPokerAction(script.Players[1], PokerAction.CreateFoldAction())); OmahaHiLoHand hand = new OmahaHiLoHand(script); Assert.AreEqual("Roger", hand.RunToEnd().Winners[0].Player.Name); mock.Verify(); }
public void RunToEnd_SeededDeck_Players2ShouldWin() { OmahaHiLoHand hand = new OmahaHiLoHand(); hand.Seed = 1; var player1 = new Mock<OmahaPlayer>(); //// AAT7 (AA669) var player2 = new Mock<OmahaPlayer>(); //// 73JQ (333JQ) -- should be winner //// 69336 (common) player1.Setup(p => p.Act()).Returns(PokerAction.CreateCallAction()).Verifiable(); player2.Setup(p => p.Act()).Returns(PokerAction.CreateCallAction()).Verifiable(); hand.Sit(player1.Object, 0, 1000); hand.Sit(player2.Object, 1, 1000); HandResult result = hand.RunToEnd(); Assert.AreEqual(1, result.Winners.Count); Assert.AreEqual(player2.Object, result.Winners[0].Player); player1.Verify(); player2.Verify(); }
public void RunToEnd_Player1HasHighPlayer2HasLow_ShouldBeTwoWinners() { HandHistory script = new HandHistory(); var mock1 = new Mock<OmahaPlayer>(); var mock2 = new Mock<OmahaPlayer>(); mock1.Setup(p => p.Act()).Returns(PokerAction.CreateCallAction()); mock2.Setup(p => p.Act()).Returns(PokerAction.CreateCallAction()); script.ButtonSeat = 0; script.SmallBlindSeat = 1; script.SmallBlindAmount = 5; script.BigBlindSeat = 0; script.BigBlindAmount = 10; script.Players[0] = new HandHistoryPlayer("John", 1000, mock1.Object); script.Players[1] = new HandHistoryPlayer("Bill", 1000, mock2.Object); script.Players[0].HoleCards = CardHelper.CreateHandFromString("Ah Ad 7h 8h"); script.Players[1].HoleCards = CardHelper.CreateHandFromString("4h 6d Th Jh"); script.FlopCards = CardHelper.CreateHandFromString("As 2s 3s"); script.TurnCard = new Card(HoldemHand.Hand.Rank8, 0); script.RiverCard = new Card(HoldemHand.Hand.Rank9, 0); OmahaHiLoHand hand = new OmahaHiLoHand(script); HandResult hr = hand.RunToEnd(); Assert.AreEqual(2, hr.Winners.Count); }