public void It_Should_Return_CorrectTimesForTalks_When_Given_AListOfTalks() { //arrange var talks = new List <Block> { new Block("Ruby on Rails: Why We Should Move On 60min", 60), new Block("Ruby on Rails Legacy App Maintenance 60min", 60), new Block("Overdoing it in Python 45min", 45), new Block("Ruby Errors from Mismatched Gem Versions 45min", 45), }; var afternoonSession = new SessionAllocator(ConfigurationLoader.LoadSessionConfiguration("afternoonSession.json")); //act afternoonSession.AllocateTalksToSession(talks); //assert var expectedTalkTimes = new List <TimeSpan> { new TimeSpan(13, 0, 0), new TimeSpan(14, 0, 0), new TimeSpan(15, 0, 0), new TimeSpan(15, 45, 0), new TimeSpan(17, 0, 0) }; var actualTalkTimes = afternoonSession.Sessions[0].Select(x => x.TimeSlot).ToList(); Assert.True(actualTalkTimes.SequenceEqual(expectedTalkTimes)); }
private void GenerateSessions(SessionAllocator sessionAllocator, List <Block> talks) { for (var i = 0; i < _numberOfTracks; i++) { sessionAllocator.AllocateTalksToSession(talks); } }
public void It_Should_Return_AListOfTalksThatFitIntoTheMorningSession_Given_AListOfTalks(List <Block> availableTalks, List <string> expectedAllocatedTalks) { //arrange var morningSession = new SessionAllocator(ConfigurationLoader.LoadSessionConfiguration("morningSession.json")); //act morningSession.AllocateTalksToSession(availableTalks); //assert Assert.Equal(expectedAllocatedTalks, morningSession.Sessions[0].Select(x => x.BlockName)); }
public void It_Should_Return_ValidTracks_Given_AListOfTalks(List <Block> talks, List <string> expectedFirstTrack) { //arrange var morningSession = new SessionAllocator(ConfigurationLoader.LoadSessionConfiguration("morningSession.json")); var afternoonSession = new SessionAllocator(ConfigurationLoader.LoadSessionConfiguration("afternoonSession.json")); var trackGenerator = new TrackGenerator(2, new List <SessionAllocator> { morningSession, afternoonSession }, new TalkDurationValidator()); //act var tracks = trackGenerator.GenerateTracks(talks); //assert var actualFirstTrack = tracks[0].Blocks.Select(t => t.BlockName).ToList(); Assert.Equal(expectedFirstTrack, actualFirstTrack); }
public void It_Should_Indicate_AllocationStatusOfAllTalks(List <Block> talks) { //arrange var morningSession = new SessionAllocator(ConfigurationLoader.LoadSessionConfiguration("morningSession.json")); var afternoonSession = new SessionAllocator(ConfigurationLoader.LoadSessionConfiguration("afternoonSession.json")); var trackGenerator = new TrackGenerator(2, new List <SessionAllocator> { morningSession, afternoonSession }, new TalkDurationValidator()); //act var tracks = trackGenerator.GenerateTracks(talks); //assert foreach (var block in tracks.SelectMany(track => track.Blocks)) { Assert.True(block.IsAllocated); } }
public void It_Should_Return_AListOfTalksThatFitIntoTheAfternoonSession_Given_AListOfTalks(List <Block> talks, List <List <string> > expectedAfternoonSessions) { //arrange var morningSession = new SessionAllocator(ConfigurationLoader.LoadSessionConfiguration("morningSession.json")); var afternoonSession = new SessionAllocator(ConfigurationLoader.LoadSessionConfiguration("afternoonSession.json")); var trackGenerator = new TrackGenerator(2, new List <SessionAllocator> { morningSession, afternoonSession }, new TalkDurationValidator()); //act trackGenerator.GenerateTracks(talks); //assert var afternoonSessions = trackGenerator.SessionAllocators[1].Sessions .Select(s => s.Select(t => t.BlockName).ToList()).ToList(); Assert.Equal(expectedAfternoonSessions, afternoonSessions); }
public void It_Should_Update_IsAllocated_ToTrue_AfterAllocatingATalk() { //arrange var talks = new List <Block> { new Block("Ruby on Rails: Why We Should Move On 60min", 60), new Block("Rails for Python Developers lightning", 5) }; var morningSession = new SessionAllocator(ConfigurationLoader.LoadSessionConfiguration("morningSession.json")); //act morningSession.AllocateTalksToSession(talks); //assert foreach (var talk in morningSession.Sessions[0]) { Assert.True(talk.IsAllocated); } }
static void Main(string[] args) { var morningSessionAllocator = new SessionAllocator( ConfigurationLoader.LoadSessionConfiguration("morningSession.json")); var afternoonSessionAllocator = new SessionAllocator( ConfigurationLoader.LoadSessionConfiguration("afternoonSession.json")); var trackGenerator = new TrackGenerator( 2, new List <SessionAllocator> { morningSessionAllocator, afternoonSessionAllocator }, new TalkDurationValidator()); var talkValidator = new TalkValidator(); var pathValidator = new PathValidator(); var conferenceTrackManager = new ConferenceTrackManager( new ConsoleDisplay(), new ConsoleInputCollector(), new TextFileInputProvider(pathValidator), new TextFileInputProcessor(talkValidator), trackGenerator); conferenceTrackManager.ManageTracks(); // /Users/amanda.chau/fma/fma-katas/ConferenceTrackManagementKata/ConferenceTrack.UnitTests/Input/OriginalTestInput.txt ///Users/amanda.chau/fma/fma-katas/ConferenceTrackManagementKata/ConferenceTrack.UnitTests/Input/InvalidTestInput.txt /// /// /Users/amanda.chau/fma/fma-katas/ConferenceTrackManagementKata/ConferenceTrack.UnitTests/Input/InvalidTalkDuration.txt }