public void Track_Generator_Returns_Valid_Track_List_With_the_Specified_Count() { int trackCount = 2; var tracks = trackManager.GenerateTracks(trackCount); Assert.AreEqual(trackCount, tracks.Count); }
public List <Track> ScheduleTalks(string [] talkInputs) { var talks = talkManager.GenerateTalksFromInput(talkInputs); var totalTalkDuration = talks.Sum(x => x.Duration); var minimumNoOfTracksRequired = trackManager.CalculateMinimumTracksRequired(totalTrackDuration, totalTalkDuration); var tracks = trackManager.GenerateTracks(minimumNoOfTracksRequired); foreach (var track in tracks) { bool morningSessionFullyAllocated = false; int morningSessionDurationInMinutes = (int)track.MorningSession.Duration.TotalMinutes; for (int talkCounter = talks.Count - 1; talkCounter >= 0; talkCounter--) { int talkDuration = talks[talkCounter].Duration; if (morningSessionDurationInMinutes >= talkDuration && !morningSessionFullyAllocated) { track.MorningSession.Talks.Add(talks[talkCounter]); morningSessionDurationInMinutes = morningSessionDurationInMinutes - talkDuration; talks.RemoveAt(talkCounter); if (morningSessionDurationInMinutes == 0) { morningSessionFullyAllocated = true; track.MorningSession.FullyAllocated = morningSessionFullyAllocated; break; } } } bool afternoonSessionFullyAllocated = false; int afternoonSessionDurationInMinutes = (int)track.AfternoonSession.Duration.TotalMinutes; for (int talkCounter = talks.Count - 1; talkCounter >= 0; talkCounter--) { int talkDuration = talks[talkCounter].Duration; if (afternoonSessionDurationInMinutes >= talkDuration && !afternoonSessionFullyAllocated) { track.AfternoonSession.Talks.Add(talks[talkCounter]); afternoonSessionDurationInMinutes = afternoonSessionDurationInMinutes - talkDuration; talks.RemoveAt(talkCounter); if (afternoonSessionDurationInMinutes == 0 || talks.Count == 0) { afternoonSessionFullyAllocated = true; track.AfternoonSession.FullyAllocated = afternoonSessionFullyAllocated; break; } } } } return(tracks); }