public void Join(Participant participant) { if (_participants.Any(p => p.Id.Equals(participant.Id))) throw new ParticipantAlreadyParticpatesInRoundException(participant.Id, participant.Name); _participants.Add(participant); participant.Estimated += RegisterEstimate; }
public void Remove(Participant participant) { var idOfParticipantToRemove = participant.Id; var participantToRemove = _participants.SingleOrDefault(p => p.Id.Equals(idOfParticipantToRemove)); if (participantToRemove == null) throw new NoSuchParticipantException(idOfParticipantToRemove); participant.Estimated -= RegisterEstimate; _participants.Remove(participant); }
public void Can_enroll_new_participant_when_there_is_no_active_round() { var roundKeeper = new RoundKeeper(); var participant = new Participant("NEW"); roundKeeper.Enroll(participant); Assert.That(roundKeeper.HasActiveRound, "roundkeeper has active round"); Assert.That(roundKeeper.ActiveRound.Status.ParticipantCount, Is.EqualTo(1), "round participant count"); }
public void Can_enroll_new_participant_when_there_is_an_active_non_completed_round() { var roundKeeper = new RoundKeeper(); var participant1 = new Participant("ONE"); var participant2 = new Participant("TWO"); roundKeeper.Enroll(participant1); roundKeeper.Enroll(participant2); Assert.That(roundKeeper.ActiveRound.Status.ParticipantCount, Is.EqualTo(2), "round participant count"); }
public void Starts_new_round_when_enrolling_new_participant_when_active_roud_is_completed() { var roundKeeper = new RoundKeeper(); var currentRoundParticipant = new Participant("ACTIVE"); var newRoundInitiatingParticipant = new Participant("NEW"); roundKeeper.Enroll(currentRoundParticipant); currentRoundParticipant.Estimate(StoryPoints.One); roundKeeper.Enroll(newRoundInitiatingParticipant); Assert.That(roundKeeper.ActiveRound.Status.ParticipantCount, Is.EqualTo(2), "participant count"); Assert.That(roundKeeper.ActiveRound.Status.EstimateCount, Is.EqualTo(0), "estimate count"); }
public ActionResult Index(RegisterForm form) { if (!ModelState.IsValid) { ModelState.AddModelError("", "Name is required!"); return View(form); } var participant = new Participant(form.Name); _roundKeeper.Enroll(participant); _appCookies.ParticipantId = participant.Id; return RedirectToAction("Estimate", "Estimation"); }
public void Enroll(Participant participant) { if (!HasActiveRound) { StartNewRound(participant); return; } if (_activeRound.Status.IsCompleted) { var newRoundParticipants = _activeRound.Partipants.Union(new[] {participant}).ToArray(); StartNewRound(newRoundParticipants); } else { participant.Participate(_activeRound); } }
public static Participant In(EstimationRound round, string name = "anonymous") { var participant = new Participant(name); participant.Participate(round); return participant; }
private void StartNewRound(Participant participant) { StartNewRound(new []{participant}); }
private void StartNewRound(Participant participant) { StartNewRound(new [] { participant }); }