public void Insert_HandWithTwoPlayers_FindsOrInsertsBothPlayerIdentities() { var player1 = new ConvertedPokerPlayer { Name = "player1" }; var player2 = new ConvertedPokerPlayer { Name = "player2" }; var playerIdentityDaoMock = _playerIdentityDaoStub; playerIdentityDaoMock .Setup(pd => pd.FindOrInsert(player1.Name, Site)) .Returns(new PlayerIdentityStub(player1.Name, Site, 1)); playerIdentityDaoMock .Setup(pd => pd.FindOrInsert(player2.Name, Site)) .Returns(new PlayerIdentityStub(player2.Name, Site, 2)); _hand .AddPlayer(player1) .AddPlayer(player2); _sut.Insert(_hand); FlushAndClearSession(); playerIdentityDaoMock.Verify(pd => pd.FindOrInsert(player1.Name, Site)); playerIdentityDaoMock.Verify(pd => pd.FindOrInsert(player2.Name, Site)); }
void CreateHandAndTriggerEvent() { var hand = new ConvertedPokerHand(PokerSites.PokerStars, _gameId++, DateTime.Now, 30, 15, TotalSeats) { TotalSeats = TotalSeats, TableName = TableName, HeroName = Player1.Name, Board = "Ah Ks Qh", }; this.ForEach(p => { if (p.IsPresent && p.SeatNumber <= TotalSeats) { var player = new ConvertedPokerPlayer(p.Name, 10, 10 + p.SeatNumber, p.SeatNumber - 1, TotalSeats, p.HoleCards) { SeatNumber = p.SeatNumber }; player.Add(new ConvertedPokerRound().Add(new ConvertedPokerAction(ActionTypes.C, 1.0))); player.Position = p.SeatNumber - 1; player.SetStrategicPosition(TotalSeats); hand.AddPlayer(player); } ; }); Log.Debug(hand.ToString()); _repository.InsertHand(hand); Log.Debug("Inserted into database"); _eventAggregator .GetEvent <NewHandEvent>() .Publish(new NewHandEventArgs(PathToHandHistoryFile, hand)); }
public void Insert_HandWithTwoPlayers_InsertsItIntoDatabase() { var player1 = new ConvertedPokerPlayer { Name = "player1" }; var player2 = new ConvertedPokerPlayer { Name = "player2" }; _playerIdentityDaoStub .Setup(pd => pd.FindOrInsert(player1.Name, Site)) .Returns(new PlayerIdentityStub(player1.Name, Site, 1)); _playerIdentityDaoStub .Setup(pd => pd.FindOrInsert(player2.Name, Site)) .Returns(new PlayerIdentityStub(player2.Name, Site, 2)); _hand .AddPlayer(player1) .AddPlayer(player2); _sut.Insert(_hand); FlushAndClearSession(); _hand.Id.ShouldNotBeEqualTo(UnsavedValue); }
public void Get_SavedPlayerIdentityTwoPlayersFromDifferentHandsWithThatIdentityInDatabase_RestoredPlayersAreEqualToStoredPlayers() { _session.Save(_identity); var player1 = new ConvertedPokerPlayer { Name = "somePlayer", PlayerIdentity = _identity }; _hand.AddPlayer(player1); _session.Save(_hand); FlushAndClearSession(); var otherHand = new ConvertedPokerHand("someSite", 1, DateTime.MinValue, 2, 1, 2); var player2 = new ConvertedPokerPlayer { Name = "somePlayer", PlayerIdentity = _identity }; otherHand.AddPlayer(player2); _session.Save(otherHand); var retrievedIdentity = _session.Get <PlayerIdentity>(_identity.Id); retrievedIdentity.ConvertedPlayers.First().ShouldBeEqualTo(player1); retrievedIdentity.ConvertedPlayers.Last().ShouldBeEqualTo(player2); }
public void RemoveInactivePlayers_PlayerHasNoRound_RemovesHim() { var convertedPlayer = new ConvertedPokerPlayer(); _convertedHand .AddPlayer(convertedPlayer) .RemoveInactivePlayers(); Assert.That(_convertedHand.Players.Count, Is.EqualTo(0)); }
void InitConvertedPokerHand() { var player1 = new ConvertedPokerPlayer("player1", 10, 5, 0, 6, "As Kd") { new ConvertedPokerRound() }; player1[Streets.PreFlop].Add(new ConvertedPokerAction(ActionTypes.C, 0.2)); var player2 = new ConvertedPokerPlayer("player2", 12, 4, 1, 6, "?? ??") { new ConvertedPokerRound() }; player2[Streets.PreFlop].Add(new ConvertedPokerAction(ActionTypes.X, 1.0)); var player3 = new ConvertedPokerPlayer("player3", 13, 2, 2, 6, "?? ??") { new ConvertedPokerRound() }; player3[Streets.PreFlop].Add(new ConvertedPokerAction(ActionTypes.C, 0.3)); var player4 = new ConvertedPokerPlayer("player4", 14, 4, 3, 6, "?? ??") { new ConvertedPokerRound() }; player4[Streets.PreFlop].Add(new ConvertedPokerAction(ActionTypes.F, 1.0)); var player5 = new ConvertedPokerPlayer("player5", 15, 3, 4, 6, "?? ??") { new ConvertedPokerRound() }; player5[Streets.PreFlop].Add(new ConvertedPokerAction(ActionTypes.C, 0.3)); var player6 = new ConvertedPokerPlayer("player6", 16, 14, 5, 6, "?? ??") { new ConvertedPokerRound() }; player6[Streets.PreFlop].Add(new ConvertedPokerAction(ActionTypes.F, 1.0)); _pokerHand = new ConvertedPokerHand("PokerStars", 1234, DateTime.MinValue, 200, 100, 6); _pokerHand.AddPlayer(player1); _pokerHand.AddPlayer(player2); _pokerHand.AddPlayer(player3); _pokerHand.AddPlayer(player4); _pokerHand.AddPlayer(player5); _pokerHand.AddPlayer(player6); _pokerHand.Ante = 50; _pokerHand.TournamentId = 2354; }
public void AffirmIsEqualTo_AreEqual_Passes() { var player1 = new ConvertedPokerPlayer { Name = "player1" }; var player2 = new ConvertedPokerPlayer { Name = "player1" }; Affirm.That(player1).IsEqualTo(player2); }
public void AffirmIsNotEqualTo_DifferentNames_Passes() { IConvertedPokerPlayer player1 = new ConvertedPokerPlayer { Name = "player1" }; IConvertedPokerPlayer player2 = new ConvertedPokerPlayer { Name = "player2" }; Affirm.That(player1).IsNotEqualTo(player2); }
public void AffirmIsNotEqualTo_DifferentRoundCount_Passes() { IConvertedPokerPlayer player1 = new ConvertedPokerPlayer { Name = "player1" } .Add(new ConvertedPokerRound()); IConvertedPokerPlayer player2 = new ConvertedPokerPlayer { Name = "player1" }; Affirm.That(player1).IsNotEqualTo(player2); }
IConvertedPokerPlayer SavePlayerIdentityAndReturnPlayerNamed(string name) { IConvertedPokerPlayer player = new ConvertedPokerPlayer { Name = name, PlayerIdentity = new PlayerIdentity(name, Site) }; _session.Save(player.PlayerIdentity); return(player); }
public void __Init() { const int someTotalPlayers = 6; const int someMBefore = 0; const int someMAfter = 0; const int somePosition = 0; string someHoleCards = string.Empty; _convertedPlayer = new ConvertedPokerPlayer(); _convertedPlayer.InitializeWith( "someName", someMBefore, someMAfter, somePosition, someTotalPlayers, someHoleCards); }
ProcessRound_PreflopAquPlayerWithOneRoundConPlayerWithNoRound_AddsPreflopRoundAndActionToConvertedPokerPlayer () { IAquiredPokerRound aquiredRound = new AquiredPokerRound() .Add(new AquiredPokerAction(_stub.Valid(For.ActionType, ActionTypes.C), _stub.Some <double>())); IConvertedPokerPlayer convertedPlayer = new ConvertedPokerPlayer(); _converter.InvokeProcessRound(Streets.PreFlop, aquiredRound, convertedPlayer); IConvertedPokerAction firstPreflopAction = convertedPlayer[Streets.PreFlop][0]; Assert.That(firstPreflopAction, Is.EqualTo(aquiredRound[0])); }
public void RemoveInactivePlayers_PlayerHasOneRoundWithOneAction_DoesntRemoveHim() { var convertedPlayer = new ConvertedPokerPlayer() .Add( new ConvertedPokerRound() .Add(new ConvertedPokerAction(ActionTypes.F, 1.0))); _convertedHand .AddPlayer(convertedPlayer) .RemoveInactivePlayers(); Assert.That(_convertedHand.Players.Count, Is.EqualTo(1)); }
public void ProcessRound_PokerPlayerWithNoRound_DoesNotReThrowNullReferenceException( [Values(Streets.PreFlop, Streets.Flop, Streets.Turn, Streets.River)] Streets street) { var convertedPlayer = new ConvertedPokerPlayer(); IAquiredPokerRound aquiredRound = new AquiredPokerRound() .Add(new AquiredPokerAction(_stub.Valid(For.ActionType, ActionTypes.C), _stub.Some <double>())); // Logs the exception and goes on TestDelegate invokeProcessRound = () => NotLogged(() => _converter.InvokeProcessRound(street, aquiredRound, convertedPlayer)); Assert.DoesNotThrow(invokeProcessRound); }
public void SetWhoHasPositionInEachRound_TwoPlayersPreflop_SetsFirstPlayerInPositionPreflopToFalse() { var player1 = new ConvertedPokerPlayer { Name = "player1" }.Add(); var player2 = new ConvertedPokerPlayer { Name = "player2" }.Add(); _convertedHand .AddPlayer(player1) .AddPlayer(player2) .SetWhoHasPositionInEachRound(); player1.InPosition[(int)Streets.PreFlop].ShouldBeFalse(); }
public void Get_SavedPlayerIdentityOnePlayerWithThatIdentityInDatabase_RestoredPlayerIsEqualStoredPlayer() { _session.Save(_identity); var player = new ConvertedPokerPlayer { Name = "somePlayer", PlayerIdentity = _identity }; _hand.AddPlayer(player); _session.Save(_hand); FlushAndClearSession(); var retrievedIdentity = _session.Get <PlayerIdentity>(_identity.Id); retrievedIdentity.ConvertedPlayers.First().ShouldBeEqualTo(player); }
public void AffirmIsEqualTo_SameRounds_Passes() { IConvertedPokerPlayer player1 = new ConvertedPokerPlayer { Name = "player1" } .Add( new ConvertedPokerRound() .Add(new ConvertedPokerAction(ActionTypes.F, 1.0))); IConvertedPokerPlayer player2 = new ConvertedPokerPlayer { Name = "player1" } .Add( new ConvertedPokerRound() .Add(new ConvertedPokerAction(ActionTypes.F, 1.0))); Affirm.That(player1).IsEqualTo(player2); }
ProcessRound_PreflopAquPlayerWithOneRoundConPlayerWithOneRound_AddsPreflopActionToConvertedPokerPlayerFirstRound () { const ActionTypes someActionType = ActionTypes.C; const double someRatio = 1.0; IAquiredPokerRound aquiredRound = new AquiredPokerRound() .Add(new AquiredPokerAction(someActionType, someRatio)); IConvertedPokerPlayer convertedPlayer = new ConvertedPokerPlayer().Add(); _converter.InvokeProcessRound(Streets.PreFlop, aquiredRound, convertedPlayer); IConvertedPokerAction firstPreflopAction = convertedPlayer[Streets.PreFlop][0]; const int first = 0; Assert.That(firstPreflopAction, Is.EqualTo(aquiredRound[first])); }
public void Get_SavedHandWithOnePlayer_RestoresPlayersParentHand() { _session.Save(_playerIdentity1); var player1 = new ConvertedPokerPlayer { PlayerIdentity = _playerIdentity1 }; _hand .AddPlayer(player1); _session.Save(_hand); FlushAndClearSession(); var retrievedHand = _session.Get <ConvertedPokerHand>(_hand.Id); retrievedHand.Players.First().ParentHand.ShouldBeEqualTo(_hand); }
public void Get_SavedHandWithOnePlayer_RestoresPlayersProperties() { _session.Save(_playerIdentity1); var player1 = new ConvertedPokerPlayer { PlayerIdentity = _playerIdentity1, Holecards = "hisCards", Position = 1 }; _hand .AddPlayer(player1); _session.Save(_hand); FlushAndClearSession(); var retrievedHand = _session.Get <ConvertedPokerHand>(_hand.Id); retrievedHand.Players.First().Holecards.ShouldBeEqualTo(player1.Holecards); retrievedHand.Players.First().Position.ShouldBeEqualTo(player1.Position); }
public void ProcessRound_PreflopAquPlayerWithOneRound_AddsActionAndPlayerIdToSequencesForCurrentRound() { const int playerPosition = 1; IConvertedPokerPlayer playerStub = new ConvertedPokerPlayer() .Add(); playerStub.Position = playerPosition; IAquiredPokerRound aquiredRound = new AquiredPokerRound() .Add(new AquiredPokerAction(_stub.Valid(For.ActionType, ActionTypes.C), _stub.Some <double>())); var expectedAction = new ConvertedPokerActionWithId(new ConvertedPokerAction(ActionTypes.C, 0), playerPosition); _converter.InvokeProcessRound(Streets.PreFlop, aquiredRound, playerStub); Assert.That(_converter.SequenceForCurrentRoundProp[0], Is.EqualTo(expectedAction)); }
public void Get_SavedPlayerIdentityOnePlayerWithThatIdentityInDatabase_RestoresPlayerLazy() { _session.Save(_identity); var player = new ConvertedPokerPlayer { Name = "somePlayer", PlayerIdentity = _identity }; _hand.AddPlayer(player); _session.Save(_hand); FlushAndClearSession(); var retrievedIdentity = _session.Get <PlayerIdentity>(_identity.Id); FlushAndClearSession(); Assert.Throws <LazyInitializationException>(() => retrievedIdentity.ConvertedPlayers.First()); }
public void IsFullFilledBy_HeroWithoutRoundOpponentWithTwoRounds_ReturnsFalse() { IConvertedPokerPlayer opponent = new ConvertedPokerPlayer( "other", _stub.Some <double>(), _stub.Some <double>(), _stub.Valid(For.Position, 0), _stub.Valid(For.TotalPlayers, 2), _stub.Valid(For.HoleCards, string.Empty)) .Add() .Add(); _convertedHand .AddPlayer(_heroPlayer); bool result = _sawFlopCondition.IsMetBy(_convertedHand); Assert.That(result, Is.False); }
public void IsFullFilledBy_InvestingOpponent_ReturnsFalse() { IConvertedPokerPlayer opponent = new ConvertedPokerPlayer( "other", _stub.Some <double>(), _stub.Some <double>(), _stub.Valid(For.Position, 0), _stub.Valid(For.TotalPlayers, 2), _stub.Valid(For.HoleCards, string.Empty)) .Add( new ConvertedPokerRound() .Add(new ConvertedPokerAction(ActionTypes.C, 1.0))); _convertedHand.AddPlayer(opponent); bool result = _investedMoneyCondition.IsMetBy(_convertedHand); Assert.That(result, Is.False); }
ProcessRound_PreflopAquPlayerWithTwoRoundsConPlayerWithOneRoundActionCountOne_AddsSecondPreflopActionAsFirstActionOfConvertedPokerPlayersFirstRound () { const ActionTypes firstActionType = ActionTypes.C; const ActionTypes secondActionType = ActionTypes.F; const double someRatio = 1.0; IAquiredPokerRound aquiredRound = new AquiredPokerRound() .Add(new AquiredPokerAction(firstActionType, someRatio)) .Add(new AquiredPokerAction(secondActionType, someRatio)); IConvertedPokerPlayer convertedPlayer = new ConvertedPokerPlayer().Add(); _converter.ActionCountProp = 1; _converter.InvokeProcessRound(Streets.PreFlop, aquiredRound, convertedPlayer); IConvertedPokerAction addedPreflopAction = convertedPlayer[Streets.PreFlop][0]; const int second = 1; Assert.That(addedPreflopAction, Is.EqualTo(aquiredRound[second])); }
public void Get_SavedHandWithTwoPlayers_RestoresPlayers() { _session.Save(_playerIdentity1); _session.Save(_playerIdentity2); var player1 = new ConvertedPokerPlayer { PlayerIdentity = _playerIdentity1 }; var player2 = new ConvertedPokerPlayer { PlayerIdentity = _playerIdentity2 }; _hand .AddPlayer(player1) .AddPlayer(player2); _session.Save(_hand); FlushAndClearSession(); var retrievedHand = _session.Get <ConvertedPokerHand>(_hand.Id); retrievedHand.Players.First().Id.ShouldBeEqualTo(player1.Id); retrievedHand.Players.Last().Id.ShouldBeEqualTo(player2.Id); }
public void BinaryDeserialized_SerializedUnInitializedPlayer_ReturnsSamePlayer() { var player = new ConvertedPokerPlayer(); Affirm.That(player.BinaryDeserializedInMemory()).IsEqualTo(player); }
public void _Init() { _convertedPlayer = new ConvertedPokerPlayer(); _stub = new StubBuilder(); }
private static IConvertedPokerHand CreateSamplePokerHand(int index) { var player1 = new ConvertedPokerPlayer("player1", 10 + index, 5, 0, 6, "As Kd"); player1.Add(new ConvertedPokerRound()); player1[Streets.PreFlop].Add(new ConvertedPokerAction(ActionTypes.C, 0.2)); player1.Add(new ConvertedPokerRound()); player1[Streets.Flop].Add(new ConvertedPokerAction(ActionTypes.B, 0.3)); player1.Add(new ConvertedPokerRound()); player1[Streets.Turn].Add(new ConvertedPokerAction(ActionTypes.B, 0.5)); player1[Streets.Turn].Add(new ConvertedPokerAction(ActionTypes.C, 0.4)); player1.Add(new ConvertedPokerRound()); player1[Streets.River].Add(new ConvertedPokerAction(ActionTypes.B, 0.9)); var player2 = new ConvertedPokerPlayer("player2", 12 + index, 4, 1, 6, "9h Qd"); player2.Add(new ConvertedPokerRound()); player2[Streets.PreFlop].Add(new ConvertedPokerAction(ActionTypes.X, 1.0)); var player3 = new ConvertedPokerPlayer("player3", 13 + index, 2, 2, 6, "?? ??"); player3.Add(new ConvertedPokerRound()); player3[Streets.PreFlop].Add(new ConvertedPokerAction(ActionTypes.C, 0.3)); player3.Add(new ConvertedPokerRound()); player3[Streets.Flop].Add(new ConvertedPokerAction(ActionTypes.C, 0.2)); player3.Add(new ConvertedPokerRound()); player3[Streets.Turn].Add(new ConvertedPokerAction(ActionTypes.R, 3.0)); player3[Streets.Turn].Add(new ConvertedPokerAction(ActionTypes.C, 0.2)); player3.Add(new ConvertedPokerRound()); player3[Streets.River].Add(new ConvertedPokerAction(ActionTypes.C, 0.2)); var player4 = new ConvertedPokerPlayer("player4", 14 + index, 4, 3, 6, "?? ??"); player4.Add(new ConvertedPokerRound()); player4[Streets.PreFlop].Add(new ConvertedPokerAction(ActionTypes.F, 1.0)); var player5 = new ConvertedPokerPlayer("player5", 15 + index, 3, 4, 6, "?? ??"); player5.Add(new ConvertedPokerRound()); player5[Streets.PreFlop].Add(new ConvertedPokerAction(ActionTypes.C, 0.3)); var player6 = new ConvertedPokerPlayer("player6", 16 + index, 14, 5, 6, "?? ??"); player6.Add(new ConvertedPokerRound()); player6[Streets.PreFlop].Add(new ConvertedPokerAction(ActionTypes.F, 1.0)); var pokerHand = new ConvertedPokerHand("PokerStars", (ulong)(32084482 + index), DateTime.Now, 200, 100, 6); pokerHand.AddPlayer(player1); pokerHand.AddPlayer(player2); pokerHand.AddPlayer(player3); pokerHand.AddPlayer(player4); pokerHand.AddPlayer(player5); pokerHand.AddPlayer(player6); pokerHand.Ante = 50; pokerHand.TournamentId = 1244353 + (ulong)index; pokerHand.Board = "As Kd 9h 3h Qd"; return(pokerHand); }