public void IsEqualTo_AreNotEqual_ReturnsFalse()
        {
            var round1 = new ConvertedPokerRound().Add(new ConvertedPokerAction(ActionTypes.F, 1.0));
            var round2 = new ConvertedPokerRound().Add(new ConvertedPokerAction(ActionTypes.C, 1.0));

            Assert.That(round1, Is.Not.EqualTo(round2));
        }
        public void ConvertPreflop_Player1IsSmallBlind__SetsSequencesCorrectly()
        {
            RelativeRatioResult   result           = ConvertPreflopThreePlayersHand();
            IConvertedPokerHand   convHand         = result.ConvertedHand;
            IConvertedPokerPlayer smallBlindPlayer = convHand[0];
            IConvertedPokerPlayer bigBlindPlayer   = convHand[1];
            IConvertedPokerPlayer buttonPlayer     = convHand[2];

            var action1 = new ConvertedPokerActionWithId(buttonPlayer[Streets.PreFlop][0], buttonPlayer.Position);
            var action2 = new ConvertedPokerActionWithId(
                smallBlindPlayer[Streets.PreFlop][0], smallBlindPlayer.Position);
            var action3 = new ConvertedPokerActionWithId(bigBlindPlayer[Streets.PreFlop][0], bigBlindPlayer.Position);
            var action4 = new ConvertedPokerActionWithId(buttonPlayer[Streets.PreFlop][1], buttonPlayer.Position);
            var action5 = new ConvertedPokerActionWithId(
                smallBlindPlayer[Streets.PreFlop][1], smallBlindPlayer.Position);
            var action6 = new ConvertedPokerActionWithId(bigBlindPlayer[Streets.PreFlop][1], bigBlindPlayer.Position);

            IConvertedPokerRound expectedPreflopSequence = new ConvertedPokerRound()
                                                           .Add(action1)
                                                           .Add(action2)
                                                           .Add(action3)
                                                           .Add(action4)
                                                           .Add(action5)
                                                           .Add(action6);

            Assert.That(expectedPreflopSequence, Is.EqualTo(convHand.Sequences[(int)Streets.PreFlop]));
        }
        public void ConvertedRoundFrom_OneActiveAction_ReturnsRoundWithThatAction(
            [Values(ActionTypes.B, ActionTypes.C, ActionTypes.R, ActionTypes.W)] ActionTypes actionType)
        {
            const double         ratio         = 0.5;
            string               csvString     = actionType.ToString() + ratio;
            IConvertedPokerRound expectedRound = new ConvertedPokerRound()
                                                 .Add(new ConvertedPokerAction(actionType, ratio));

            IConvertedPokerRound round = _converter.ConvertedRoundFrom(csvString);

            Assert.That(round, Is.EqualTo(expectedRound));
        }
 public MockPokerRoundsConverter(
     IConstructor <IConvertedPokerActionWithId> convertedActionWithId,
     IConstructor <IConvertedPokerRound> convertedRound,
     IPokerActionConverter actionConverter)
     : base(convertedActionWithId, convertedRound, actionConverter)
 {
     ActionCountProp             = 0;
     FoundActionProp             = false;
     PotProp                     = 0;
     SequenceForCurrentRoundProp = new ConvertedPokerRound();
     SequenceSoFarProp           = string.Empty;
     ToCallProp                  = 0;
 }
        public void ConvertedRoundFrom_OneInactiveAction_ReturnsRoundWithThatAction(
            [Values(ActionTypes.A, ActionTypes.F, ActionTypes.X)] ActionTypes actionType)
        {
            _stub.Value(For.Ratio).Is(1.0);

            string csvString = actionType.ToString();
            IConvertedPokerRound expectedRound = new ConvertedPokerRound()
                                                 .Add(new ConvertedPokerAction(actionType, _stub.Out <double>(For.Ratio)));

            IConvertedPokerRound round = _converter.ConvertedRoundFrom(csvString);

            Assert.That(round, Is.EqualTo(expectedRound));
        }
        public void ConvertedRoundFrom_TwoActiveActions_ReturnsRoundWithBothActions()
        {
            const ActionTypes actionType1 = ActionTypes.B;
            const double      ratio1      = 0.5;
            const ActionTypes actionType2 = ActionTypes.C;
            const double      ratio2      = 0.2;

            string csvString =
                actionType1.ToString() + ratio1 + "," +
                actionType2 + ratio2;

            IConvertedPokerRound expectedRound = new ConvertedPokerRound()
                                                 .Add(new ConvertedPokerAction(actionType1, ratio1))
                                                 .Add(new ConvertedPokerAction(actionType2, ratio2));

            IConvertedPokerRound round = _converter.ConvertedRoundFrom(csvString);

            Assert.That(round, Is.EqualTo(expectedRound));
        }
Ejemplo n.º 7
0
        public void Get_SavedPlayer_RestoresRoundsArray()
        {
            var sampleRound = new ConvertedPokerRound()
                              .Add(new ConvertedPokerAction(ActionTypes.B, 1.0));

            _player
            .Add(sampleRound)
            .Add(sampleRound)
            .Add(sampleRound)
            .Add(sampleRound);

            _hand.AddPlayer(_player);
            _session.Save(_hand);

            FlushAndClearSession();

            IConvertedPokerPlayer retrievedPlayer = _session.Get <ConvertedPokerPlayer>(_player.Id);

            retrievedPlayer.Rounds.ShouldBeEqualTo(_player.Rounds);
        }
Ejemplo n.º 8
0
        public void Get_SavedHand_RestoresSequencesArray()
        {
            var samplePreflopRound = new ConvertedPokerRound()
                                     .Add(new ConvertedPokerAction(ActionTypes.C, 1.0));
            var sampleFlopRound = new ConvertedPokerRound()
                                  .Add(new ConvertedPokerAction(ActionTypes.B, 1.0));
            var sampleTurnRound = new ConvertedPokerRound()
                                  .Add(new ConvertedPokerAction(ActionTypes.R, 1.0));
            var sampleRiverRound = new ConvertedPokerRound()
                                   .Add(new ConvertedPokerAction(ActionTypes.B, 2.0));

            _hand.Sequences[(int)Streets.PreFlop] = samplePreflopRound;
            _hand.Sequences[(int)Streets.Flop]    = sampleFlopRound;
            _hand.Sequences[(int)Streets.Turn]    = sampleTurnRound;
            _hand.Sequences[(int)Streets.River]   = sampleRiverRound;

            _session.Save(_hand);

            FlushAndClearSession();

            var retrievedHand = _session.Get <ConvertedPokerHand>(_hand.Id);

            retrievedHand.Sequences.ShouldBeEqualTo(_hand.Sequences);
        }
        public void BinaryDeserialize_SerializedEmptyRound_ReturnsSameRound()
        {
            var round = new ConvertedPokerRound();

            Assert.That(round.BinaryDeserializedInMemory(), Is.EqualTo(round));
        }
 public void _Init()
 {
     _stub      = new StubBuilder();
     _round     = new ConvertedPokerRound();
     _converter = new PokerHandStringConverter();
 }