public void UnselectAllShownHandHistories_TwoSelectedHandsTotalButOnlyOneHandShown_UnselectsOneHand() { var hand1 = new ConvertedPokerHand { Id = 1 }; var hand2 = new ConvertedPokerHand { Id = 2 }; var hands = new List <IConvertedPokerHand> { hand1, hand2 }; var filterCondition = new StubConditionWithHandId { HandIdToMatch = hand1.Id }; _viewModel .InitializeWith(hands) .SelectAllShownHandHistoriesCommand.Execute(null); _viewModel .ApplyFilter(filterCondition) .UnselectAllShownHandHistoriesCommand.Execute(null); Assert.That(_viewModel.SelectedHandHistories.Count(), Is.EqualTo(1)); }
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); }
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 AffirmIsNotEqualTo_HandsBigBlindsAreDifferent_Passes() { var hand1 = InitializeConvertedHandWithSomeValidValues(); var hand2 = new ConvertedPokerHand( hand1.Site, hand1.GameId, hand1.TimeStamp, hand1.BB + 1, hand1.SB, hand1.TotalPlayers); Affirm.That(hand1).IsNotEqualTo(hand2); }
public void InitializeWith_OneHand_AddsOneHandHistoryViewModels() { var hand = new ConvertedPokerHand(); var hands = new List <IConvertedPokerHand> { hand }; _viewModel.InitializeWith(hands); Assert.That(_viewModel.HandHistoriesOnPage.Count(), Is.EqualTo(1)); }
public void BinaryDeserialize_Serialized_RestoresItemsHandHistoriesOnPage() { var hand1 = new ConvertedPokerHand(); var hand2 = new ConvertedPokerHand(); var hands = new List <IConvertedPokerHand> { hand1, hand2 }; _viewModel.InitializeWith(hands); Assert.That(_viewModel.BinaryDeserializedInMemory().HandHistoriesOnPage, Is.EqualTo(_viewModel.HandHistoriesOnPage)); }
public void InitializeWith_TwoHands_AddsTwoHandHistoryViewModels() { var hand1 = new ConvertedPokerHand(); var hand2 = new ConvertedPokerHand(); var hands = new List <IConvertedPokerHand> { hand1, hand2 }; _viewModel.InitializeWith(hands); Assert.That(_viewModel.HandHistoriesOnPage.Count(), Is.EqualTo(2)); }
void SaveHandWithPlayers(ulong gameId, IEnumerable <IConvertedPokerPlayer> players) { var hand = new ConvertedPokerHand("someSite", gameId, DateTime.MinValue, 10, 5, players.Count()); foreach (var player in players) { hand.AddPlayer(player); } _session.Save(hand); FlushAndClearSession(); }
public void BinaryDeserialize_Serialized_RestoresPageNumbers() { var hand1 = new ConvertedPokerHand(); var hand2 = new ConvertedPokerHand(); var hands = new List <IConvertedPokerHand> { hand1, hand2 }; _viewModel .InitializeWith(hands); Assert.That(_viewModel.BinaryDeserializedInMemory().PageNumbers, Is.EqualTo(_viewModel.PageNumbers)); }
public void SelectAllShownHandHistories_TwoHandsShownAndTwoOnPage_SelectsTwoHands() { var hand1 = new ConvertedPokerHand(); var hand2 = new ConvertedPokerHand(); var hands = new List <IConvertedPokerHand> { hand1, hand2 }; _viewModel .InitializeWith(hands) .SelectAllShownHandHistoriesCommand.Execute(null); Assert.That(_viewModel.SelectedHandHistories.Count(), Is.EqualTo(2)); }
public void InitializeWith_OneHandWithoutHeroName_DoesNotAssignHeroNameToFilterHeroName() { var handHistoriesFilter_Mock = new Mock <IHandHistoriesFilter>(); var hand = new ConvertedPokerHand(); var hands = new List <IConvertedPokerHand> { hand }; _container .RegisterInstance(handHistoriesFilter_Mock.Object) .Resolve <IHandHistoriesViewModel>() .InitializeWith(hands); handHistoriesFilter_Mock.VerifySet(f => f.HeroName = It.IsAny <string>(), Times.Never()); }
public void SelectAllHandHistoriesOnPage_TwoHandsShownButOnlyOneHandOnPage_SelectsOneHand() { var hand1 = new ConvertedPokerHand(); var hand2 = new ConvertedPokerHand(); var hands = new List <IConvertedPokerHand> { hand1, hand2 }; _viewModel .InitializeWith(hands) .HandHistoriesOnPage.RemoveAt(0); _viewModel .SelectAllHandHistoriesOnPageCommand.Execute(null); Assert.That(_viewModel.SelectedHandHistories.Count(), Is.EqualTo(1)); }
public void InitializeWith_OneHandWithHeroName_AssignsHeroNameToFilterHeroName() { var handHistoriesFilter_Mock = new Mock <IHandHistoriesFilter>(); const string heroName = "some hero"; var hand = new ConvertedPokerHand { HeroName = heroName }; var hands = new List <IConvertedPokerHand> { hand }; _container .RegisterInstance(handHistoriesFilter_Mock.Object) .Resolve <IHandHistoriesViewModel>() .InitializeWith(hands); handHistoriesFilter_Mock.VerifySet(f => f.HeroName = heroName); }
RelativeRatioResult ConvertPreflopHeadsUpHand() { _stub .Value(For.HoleCards).Is(string.Empty); const double smallBlind = 1.0; const double bigBlind = 2.0; const double pot = smallBlind + bigBlind; const double toCall = bigBlind; const int totalPlayers = 2; const int smallBlindPosition = 0; const int bigBlindPosition = 1; var action1 = new AquiredPokerAction(ActionTypes.C, smallBlind); const double relativeRatio1 = smallBlind / pot; const double pot1 = pot + smallBlind; var action2 = new AquiredPokerAction(ActionTypes.R, toCall * 2); const double relativeRatio2 = 2; const double pot2 = pot1 + (toCall * 2); var action3 = new AquiredPokerAction(ActionTypes.R, toCall * 2 * 3); const double relativeRatio3 = 3; const double pot3 = pot2 + (toCall * 2 * 3); var action4 = new AquiredPokerAction(ActionTypes.C, toCall * 2 * 3); const double relativeRatio4 = (toCall * 2 * 3) / pot3; IAquiredPokerPlayer player1 = new AquiredPokerPlayer( _stub.Some <long>(), smallBlindPosition, _stub.Out <string>(For.HoleCards)) .AddRound( new AquiredPokerRound() .Add(action1) .Add(action3)); player1.Name = "player1"; player1.Position = smallBlindPosition; IAquiredPokerPlayer player2 = new AquiredPokerPlayer( _stub.Some <long>(), bigBlindPosition, _stub.Out <string>(For.HoleCards)) .AddRound( new AquiredPokerRound() .Add(action2) .Add(action4)); player2.Name = "player2"; player2.Position = bigBlindPosition; IAquiredPokerHand aquiredHand = new AquiredPokerHand( _stub.Valid(For.Site, "site"), _stub.Out <ulong>(For.GameId), _stub.Out <DateTime>(For.TimeStamp), smallBlind, bigBlind, totalPlayers) .AddPlayer(player1) .AddPlayer(player2); IConvertedPokerHand convertedHand = new ConvertedPokerHand(aquiredHand) .InitializeWith(aquiredHand) .AddPlayersFrom(aquiredHand, pot, _convertedPlayerMake); _converter .InitializeWith(aquiredHand, convertedHand, pot, toCall) .ConvertPreflop(); var player1FirstRound = convertedHand[smallBlindPosition][Streets.PreFlop]; var player2FirstRound = convertedHand[bigBlindPosition][Streets.PreFlop]; return(new RelativeRatioResult(convertedHand, player1FirstRound, player2FirstRound, relativeRatio1, relativeRatio2, relativeRatio3, relativeRatio4)); }
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); }
RelativeRatioResult ConvertPreflopThreePlayersHand() { _stub .Value(For.HoleCards).Is(string.Empty); const double smallBlind = 1.0; const double bigBlind = 2.0; const double pot = smallBlind + bigBlind; const int totalPlayers = 3; const int smallBlindPosition = 0; const int bigBlindPosition = 1; const int buttonPosition = 2; var action1 = new AquiredPokerAction(ActionTypes.B, bigBlind); const double relativeRatio1 = bigBlind / pot; const double pot1 = pot + bigBlind; var action2 = new AquiredPokerAction(ActionTypes.C, bigBlind); const double relativeRatio2 = bigBlind / pot1; const double pot2 = pot1 + bigBlind; var action3 = new AquiredPokerAction(ActionTypes.R, bigBlind * 3); const double relativeRatio3 = 3; const double pot3 = pot2 + (bigBlind * 3); var action4 = new AquiredPokerAction(ActionTypes.R, bigBlind * 3 * 2); const double relativeRatio4 = 2; const double pot4 = pot3 + (bigBlind * 3 * 2); var action5 = new AquiredPokerAction(ActionTypes.C, bigBlind * 3 * 2); const double relativeRatio5 = (bigBlind * 2 * 3) / pot4; var action6 = new AquiredPokerAction(ActionTypes.F, 1.0); // Small Blind IAquiredPokerPlayer player1 = new AquiredPokerPlayer( _stub.Some <long>(), smallBlindPosition, _stub.Out <string>(For.HoleCards)) // Preflop .AddRound( new AquiredPokerRound() .Add(new AquiredPokerAction(ActionTypes.C, 0.5))) // Flop .AddRound( new AquiredPokerRound() .Add(action1) .Add(action4)); player1.Name = "player1"; player1.Position = smallBlindPosition; // Big Blind IAquiredPokerPlayer player2 = new AquiredPokerPlayer( _stub.Some <long>(), bigBlindPosition, _stub.Out <string>(For.HoleCards)) // Preflop .AddRound( new AquiredPokerRound() .Add(new AquiredPokerAction(ActionTypes.X, 1.0))) // Flop .AddRound( new AquiredPokerRound() .Add(action2) .Add(action5)); player2.Name = "player2"; player2.Position = bigBlindPosition; // Button IAquiredPokerPlayer player3 = new AquiredPokerPlayer( _stub.Some <long>(), buttonPosition, _stub.Out <string>(For.HoleCards)) // Preflop .AddRound( new AquiredPokerRound() .Add(new AquiredPokerAction(ActionTypes.C, 1.0))) // Flop .AddRound( new AquiredPokerRound() .Add(action3) .Add(action6)); player3.Name = "player3"; player3.Position = buttonPosition; IAquiredPokerHand aquiredHand = new AquiredPokerHand( _stub.Valid(For.Site, "site"), _stub.Out <ulong>(For.GameId), _stub.Out <DateTime>(For.TimeStamp), smallBlind, bigBlind, totalPlayers) .AddPlayer(player1) .AddPlayer(player2) .AddPlayer(player3); IConvertedPokerHand convertedHand = new ConvertedPokerHand(aquiredHand) .AddPlayersFrom(aquiredHand, pot, _convertedPlayerMake); _converter .InitializeWith(aquiredHand, convertedHand, pot, bigBlind) .ConvertPreflop(); // Reset Values _converter.PotProp = pot; _converter.ToCallProp = bigBlind; _converter.ConvertFlopTurnAndRiver(); IConvertedPokerRound player1FlopRound = convertedHand[smallBlindPosition][Streets.Flop]; IConvertedPokerRound player2FlopRound = convertedHand[bigBlindPosition][Streets.Flop]; IConvertedPokerRound player3FlopRound = convertedHand[buttonPosition][Streets.Flop]; return(new RelativeRatioResult( convertedHand, player1FlopRound, player2FlopRound, player3FlopRound, relativeRatio1, relativeRatio2, relativeRatio3, relativeRatio4, relativeRatio5)); }