public Conference GreedyBestFitApproach(IEnumerable <Talk> talks)
        {
            talks = talks.OrderBy(talk => talk);

            Conference conference = new Conference(new TrackTwoSessionsFactory());

            foreach (Talk talk in talks)
            {
                Session bestSession = GetBestSessionBestFitApproach(conference.EnumerateSessions(), talk);

                if (bestSession == null)
                {
                    conference.CreateNewTrack();
                    bestSession = GetBestSessionBestFitApproach(conference.EnumerateSessions(), talk);
                }

                if (bestSession == null)
                {
                    throw new ArgumentException(string.Format("ErrorUnscheduledEvent", talk));
                }

                bestSession.AcceptTalk(talk);
            }
            return(conference);
        }
예제 #2
0
        public void CreateNewTrack_Test()
        {
            var factoryMock = new Mock <ITrackFactory>();

            Tracker track = new TrackTwoSessions("TestTracker");

            factoryMock.Setup(factory => factory.CreateTrack("TestTracker")).Returns(track);

            Conference conference = new Conference(factoryMock.Object);

            conference.CreateNewTrack();

            factoryMock.VerifyAll();
        }