public void IsFullFilledBy_HeroWithOneRound_ReturnsFalse()
        {
            _heroPlayer
            .Add();

            _convertedHand
            .AddPlayer(_heroPlayer);

            bool result = _sawFlopCondition.IsMetBy(_convertedHand);

            Assert.That(result, Is.False);
        }
Пример #2
0
        public void IsFullFilledBy_FoldingHero_ReturnsFalse()
        {
            _heroPlayer
            .Add(
                new ConvertedPokerRound()
                .Add(new ConvertedPokerAction(ActionTypes.F, 1.0)));

            _convertedHand
            .AddPlayer(_heroPlayer);

            bool result = _investedMoneyCondition.IsMetBy(_convertedHand);

            Assert.That(result, Is.False);
        }
        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 RemoveInactivePlayers_PlayerHasNoRound_RemovesHim()
        {
            var convertedPlayer = new ConvertedPokerPlayer();

            _convertedHand
            .AddPlayer(convertedPlayer)
            .RemoveInactivePlayers();

            Assert.That(_convertedHand.Players.Count, Is.EqualTo(0));
        }
        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);
        }
Пример #6
0
        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);
        }
Пример #7
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;
        }
        void ExtractPlayersFromDatabase(int handId, IConvertedPokerHand convertedHand)
        {
            string query = string.Format(
                "SELECT * FROM {0} WHERE {1} = {2};",
                Tables.actionhhd,
                ActionTable.handid,
                handId);

            using (IDataReader dr = _dataProvider.ExecuteQuery(query))
            {
                // Iterate through all found players
                while (dr.Read())
                {
                    IConvertedPokerPlayer convPlayer = ExtractPlayer(dr);

                    convertedHand.AddPlayer(convPlayer);
                }
            }

            ExtractNamesForAllPlayers(convertedHand);

            convertedHand.SetStrategicPositionsForAllPlayers();
        }
Пример #9
0
        public void SaveParentHand_UnsavedPlayer_SetsId()
        {
            _hand.AddPlayer(_player);
            _session.Save(_hand);

            _player.Id.ShouldNotBeEqualTo(UnsavedValue);
        }