public BettingRound CreateRound(List <User> playersInRound, int roundNumber, Hand hand, Game game) { var round = new BettingRound { Id = Guid.NewGuid(), Hand = hand, Round = roundNumber, }; hand.Rounds.Add(round); var hasOnePersonBet = false; foreach (var user in playersInRound) { var betValue = _random.Next(hasOnePersonBet ? 0 : 1, 4); if (betValue > 0) { betValue = Convert.ToInt32(game.MinBet * _random.Next(1, 4)); hasOnePersonBet = true; } round.Bets.Add(new Bet { Id = Guid.NewGuid(), Round = round, Player = user, Value = betValue }); } return(round); }
When_a_betting_reound_with_an_earlier_default_end_date_then_contests_start_date_is_added_Then_an_exception_is_thrown () { var bettingRoundName = "name"; var newBettingRound = new BettingRound(bettingRoundName, Target.StartDate - new TimeSpan(12, 0, 0), Target.StartDate - new TimeSpan(0, 0, 1), 1, Target); Assert.Throws <InvalidOperationException>(() => Target.AddBettingRound(newBettingRound)); }
public void When_a_betting_round_is_passed_Then_the_passed_round_is_added_to_the_list_of_betting_rounds() { var bettingRoundName = "name"; var newBettingRound = new BettingRound(bettingRoundName, new DateTime(2015, 07, 18), new DateTime(2015, 07, 19), 1, Target); Target.AddBettingRound(newBettingRound); Assert.IsNotNull(Target.BettingRounds.Single(item => item == newBettingRound)); }
When_a_betting_round_with_a_name_that_is_allready_present_in_the_list_of_betting_rounds_is_added_Then_an_Exception_is_thrown () { var bettingRoundName = "name"; var newBettingRound = new BettingRound(bettingRoundName, new DateTime(2015, 07, 18), new DateTime(2015, 07, 19), 1, Target); Target.AddBettingRound(newBettingRound); var duplicateBettingRound = new BettingRound(bettingRoundName, new DateTime(2015, 07, 18), new DateTime(2015, 07, 19), 1, Target); Assert.Throws <InvalidOperationException>(() => Target.AddBettingRound(duplicateBettingRound)); }
When_a_betting_round_with_a_name_taht_is_allready_present_in_the_list_of_betting_rounds_and_with_whitespaces_is_added_Then_an_Exception_is_thrown () { var bettingRoundName = "name"; var defaultRoundEndDate = Target.StartDate + new TimeSpan(0, 0, 1); var newBettingRound = new BettingRound(bettingRoundName, Target.StartDate, defaultRoundEndDate, 1, Target); Target.AddBettingRound(newBettingRound); var duplicateBettingRound = new BettingRound(" " + bettingRoundName + " ", Target.StartDate, defaultRoundEndDate, 1, Target); Assert.Throws <InvalidOperationException>(() => Target.AddBettingRound(duplicateBettingRound)); }
void given_a_4_players_preflop_betting_round() { BettingRound round = null; Position dealer = null, sb = null, bb = null, utg = null; before = () => { var playerStub = new Player(); var fearfulPlayer = new Player(); utg = new Position(playerStub); bb = new Position(fearfulPlayer); sb = new Position(playerStub); dealer = new Position(playerStub); var positions = new Positions(dealer, sb, bb, utg); round = new BettingRound(new Pot(), positions); }; context["given big blind is so fearful"] = () => { context["that everyone run away"] = () => { before = () => { round.PlaceAction(Action.Fold(utg)); round.PlaceAction(Action.Fold(dealer)); round.PlaceAction(Action.Fold(sb)); }; it["big blind must not act"] = expect <EndOfRoundException>(() => round.PlaceAction(Action.Fold(bb))); it["big blind wins the pot"] = () => round.Pot.Winner.should_be(bb.Player); }; }; }
public void When_a_default_start_bet_date_is_passed_as_parameter_Then_the_DefaultDate_is_set_to_passed_value() { var bettingRound = new BettingRound(_sampleName, _sampleDefaultStartDate, _sampleDefaultEndDate, _sampleNumberOfPoints, _sampleBettingContest); Assert.AreEqual(_sampleDefaultStartDate, bettingRound.DefaultBettingStartDate); }
public void When_a_default_number_of_points_per_bet_is_passed_as_parameter_Then_the_DefultNumberOfPointsForBet_is_set_to_passed_value() { var bettingRound = new BettingRound(_sampleName, _sampleDefaultStartDate, _sampleDefaultEndDate, _sampleNumberOfPoints, _sampleBettingContest); Assert.AreEqual(_sampleNumberOfPoints, bettingRound.DefultNumberOfPointsForBet); }
private bool ShouldShow(BettingRound roundToShow, BettingRound currentRound) { return((int)currentRound >= (int)roundToShow); }
void given_a_4_players_preflop_betting_round() { BettingRound round = null; Position dealer = null, sb = null, bb = null, utg = null; before = () => { var playerStub = new Player(); utg = new Position(playerStub); bb = new Position(playerStub); sb = new Position(playerStub); dealer = new Position(playerStub); var positions = new Positions(dealer, sb, bb, utg); round = new BettingRound(new Pot(), positions); }; context["given betting round just started"] = () => { it["under the gun may act"] = () => round.PlaceAction(Action.Call(utg)); it["dealer must not act"] = expect <OutOfTurnException>(() => round.PlaceAction(Action.Fold(dealer))); it["small blind must not act"] = expect <OutOfTurnException>(() => round.PlaceAction(Action.Call(sb))); it["big blind must not act"] = expect <OutOfTurnException>(() => round.PlaceAction(Action.Fold(bb))); context["given under the gun acted"] = () => { before = () => round.PlaceAction(Action.Call(utg)); it["dealer may act"] = () => round.PlaceAction(Action.Call(dealer)); it["under the gun must not act"] = expect <OutOfTurnException>(() => round.PlaceAction(Action.Fold(utg))); it["small blind must not act"] = expect <OutOfTurnException>(() => round.PlaceAction(Action.Call(sb))); it["big blind must not act"] = expect <OutOfTurnException>(() => round.PlaceAction(Action.Fold(bb))); context["given dealer acted"] = () => { before = () => round.PlaceAction(Action.Call(dealer)); it["small blind may act"] = () => round.PlaceAction(Action.Call(sb)); it["big blind must not act"] = expect <OutOfTurnException>(() => round.PlaceAction(Action.Fold(bb))); it["under the gun must not act"] = expect <OutOfTurnException>(() => round.PlaceAction(Action.Call(utg))); it["dealer must not act"] = expect <OutOfTurnException>(() => round.PlaceAction(Action.Fold(dealer))); context["given small blind acted"] = () => { before = () => round.PlaceAction(Action.Call(sb)); it["big blind may act"] = () => round.PlaceAction(Action.Call(bb)); it["under the gun must not act"] = expect <OutOfTurnException>(() => round.PlaceAction(Action.Fold(utg))); it["dealer must not act"] = expect <OutOfTurnException>(() => round.PlaceAction(Action.Call(dealer))); it["small blind must not act"] = expect <OutOfTurnException>(() => round.PlaceAction(Action.Fold(sb))); }; }; }; }; }