Ejemplo n.º 1
0
        public void SeparatingSessionsInTheSameTrackIntoDifferentTimslots_4Sessions3Tracks()
        {
            var sessions = new SessionsCollection();

            sessions.Add(1, 1, Presenter.Create(1));
            sessions.Add(2, 2, Presenter.Create(2));
            sessions.Add(3, 1, Presenter.Create(3));
            sessions.Add(4, 3, Presenter.Create(4));

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));
            rooms.Add(Room.Create(2, 10));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1, 9.0));
            timeslots.Add(Timeslot.Create(2, 10.25));

            var engine = (null as IConferenceOptimizer).Create();

            var assignments = engine.Process(sessions, rooms, timeslots);

            assignments.WriteSchedule();

            var s1TimeslotId = assignments.Where(a => a.SessionId == 1).Single().TimeslotId;
            var s3TimeslotId = assignments.Where(a => a.SessionId == 3).Single().TimeslotId;

            Assert.That(s1TimeslotId, Is.Not.EqualTo(s3TimeslotId), "Sessions with the same TopicId should not be in the same timeslot.");
        }
Ejemplo n.º 2
0
        public void AssigningAllSessions()
        {
            var sessions = new SessionsCollection();

            sessions.Add(1, null, Presenter.Create(1));
            sessions.Add(2, null, Presenter.Create(2));
            sessions.Add(3, null, Presenter.Create(2));
            sessions.Add(4, null, Presenter.Create(3));
            sessions.Add(5, null, Presenter.Create(3));
            sessions.Add(6, null, Presenter.Create(3));
            sessions.Add(7, null, Presenter.Create(3));

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));
            rooms.Add(Room.Create(2, 10));
            rooms.Add(Room.Create(3, 10));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1));
            timeslots.Add(Timeslot.Create(2));
            timeslots.Add(Timeslot.Create(3));
            timeslots.Add(Timeslot.Create(4));
            timeslots.Add(Timeslot.Create(5));

            var engine = (null as IConferenceOptimizer).Create();

            var assignments             = engine.Process(sessions, rooms, timeslots);
            var assignmentsWithSessions = assignments.Where(a => a.SessionId.HasValue);

            assignments.WriteSchedule();
            Assert.That(assignmentsWithSessions.Count(), Is.EqualTo(sessions.Count()), "The wrong number of assignments were returned.");
        }
        public void ResultInTheSameNumberOfAssignments()
        {
            var sessions = new SessionsCollection();

            sessions.Add(1, null, Presenter.Create(1));
            sessions.Add(2, 1, Presenter.Create(2));
            sessions.Add(3, null, Presenter.Create(3));
            sessions.Add(4, 1, Presenter.Create(4));

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));
            rooms.Add(Room.Create(2, 10));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1, 9.0));
            timeslots.Add(Timeslot.Create(2, 10.25));

            var solution = new Solution(sessions, rooms, timeslots);

            while (solution.AssignmentsCompleted < sessions.Count())
            {
                solution.AssignSessionsWithOnlyOneOption();
                solution.AssignMostConstrainedSession();
            }

            var s2 = solution.SwapAssignments();

            Assert.AreEqual(solution.Assignments.Count(), s2.Assignments.Count());
        }
        public void PuttingSessionsInTheSameTrackIntoTheSameRoom_4Sessions1Track()
        {
            var sessions = new SessionsCollection();

            sessions.Add(1, 1, Presenter.Create(1));
            sessions.Add(2, 2, Presenter.Create(2));
            sessions.Add(3, 1, Presenter.Create(3));
            sessions.Add(4, 3, Presenter.Create(4));

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));
            rooms.Add(Room.Create(2, 10));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1, 9.0));
            timeslots.Add(Timeslot.Create(2, 10.25));

            var engine = (null as IConferenceOptimizer).Create();

            var assignments = engine.Process(sessions, rooms, timeslots);

            assignments.WriteSchedule();

            var s1RoomId = assignments.Where(a => a.SessionId == 1).Single().RoomId;
            var s3RoomId = assignments.Where(a => a.SessionId == 3).Single().RoomId;

            // Sessions with the same TopicId should be in the same room whenever possible
            Assert.Equal(s1RoomId, s3RoomId);
        }
Ejemplo n.º 5
0
        public void NotAssigningASessionToARoomWhenItIsNotAvailableInTimesdlot2()
        {
            var engine = (null as IConferenceOptimizer).Create();

            var sessions = new SessionsCollection();

            sessions.Add(1, null, Presenter.Create(1));
            sessions.Add(2, null, Presenter.Create(2));
            sessions.Add(3, null, Presenter.Create(3));

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));
            rooms.Add(Room.Create(2, 10, 2));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1));
            timeslots.Add(Timeslot.Create(2));

            var assignments     = engine.Process(sessions, rooms, timeslots);
            var checkAssignment = assignments.Where(a => a.RoomId == 2 && a.TimeslotId == 2).SingleOrDefault();

            assignments.WriteSchedule();

            if (checkAssignment == null)
            {
                Assert.Null(checkAssignment);
            }
            else
            {
                // No session should have been assigned to room 2 during timeslot 2
                Assert.Null(checkAssignment.SessionId);
            }
        }
Ejemplo n.º 6
0
 public static void PlannedMaintenanceJobShouldFallWithinOneBusinessDay(this PlanMaintenanceJob command)
 {
     if (!Timeslot.Create(command.StartTime, command.EndTime).IsWithinOneDay())
     {
         throw new BusinessRuleViolationException("Start-time and end-time of a Maintenance Job must be within a 1 day.");
     }
 }
        public void SeparatingSessionsInTheSameTrackIntoDifferentTimslots_4Sessions1Track()
        {
            var sessions = new SessionsCollection();

            sessions.Add(1, null, Presenter.Create(1));
            sessions.Add(2, 1, Presenter.Create(2));
            sessions.Add(3, null, Presenter.Create(3));
            sessions.Add(4, 1, Presenter.Create(4));

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));
            rooms.Add(Room.Create(2, 10));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1, 9.0));
            timeslots.Add(Timeslot.Create(2, 10.25));

            var engine = (null as IConferenceOptimizer).Create();

            var assignments = engine.Process(sessions, rooms, timeslots);

            assignments.WriteSchedule();

            var s2TimeslotId = assignments.Where(a => a.SessionId == 2).Single().TimeslotId;
            var s4TimeslotId = assignments.Where(a => a.SessionId == 4).Single().TimeslotId;

            // Sessions with the same TopicId should not be in the same timeslot
            Assert.NotEqual(s2TimeslotId, s4TimeslotId);
        }
        public void ThrowingNoFeasibleSolutionIfSpeakerWouldHaveToBeInTwoPlacesAtOnce3SessionsFor1SpeakerWith2Timeslots()
        {
            var speaker1 = Presenter.Create(1);
            var speaker2 = Presenter.Create(2);

            var sessions = new SessionsCollection();

            sessions.Add(1, null, speaker1);
            sessions.Add(2, null, speaker1);
            sessions.Add(3, null, speaker2);
            sessions.Add(4, null, speaker1);

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));
            rooms.Add(Room.Create(2, 10));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1));
            timeslots.Add(Timeslot.Create(2));

            var engine = (null as IConferenceOptimizer).Create();

            Assert.Throws <Exceptions.NoFeasibleSolutionsException>(() => engine.Process(sessions, rooms, timeslots));
        }
        public void ThrowingDependencyExceptionIfCircularDependenciesExist()
        {
            var presenter1 = Presenter.Create(1, new int[] { 2 });

            var sessions = new SessionsCollection();

            var session1 = sessions.Add(1, 1, Presenter.Create(1));
            var session2 = sessions.Add(2, 1, Presenter.Create(2));
            var session3 = sessions.Add(3, 1, Presenter.Create(3));

            session1.AddDependency(session2);
            session2.AddDependency(session3);
            session3.AddDependency(session1);

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));
            rooms.Add(Room.Create(2, 10));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1));
            timeslots.Add(Timeslot.Create(2));

            var engine = (null as IConferenceOptimizer).Create();

            Assert.Throws <Exceptions.DependencyException>(() => engine.Process(sessions, rooms, timeslots));

            Assert.Throws <Exceptions.DependencyException>(() => engine.Process(sessions, rooms, timeslots));
        }
        public void ReturningTheOnlyPossibleAssignmentIfTheSecondSessionIsDependentOnTheFirst()
        {
            var engine = (null as IConferenceOptimizer).Create();

            var sessions = new SessionsCollection();
            var session1 = sessions.Add(1, null, Presenter.Create(1));
            var session2 = sessions.Add(2, null, Presenter.Create(1));

            session2.AddDependency(session1);

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1, 10));
            timeslots.Add(Timeslot.Create(2, 11));

            var assignments        = engine.Process(sessions, rooms, timeslots);
            var session2Assignment = assignments.Where(a => a.SessionId.Value == 2).Single();

            assignments.WriteSchedule();
            Assert.That(session2Assignment.TimeslotId, Is.EqualTo(2), "Session 2 must be assigned to timeslot 2 to satisfy the dependencies.");
        }
Ejemplo n.º 11
0
    private void Handle(MaintenanceJobFinished e)
    {
        MaintenanceJob job            = Jobs.FirstOrDefault(j => j.Id == e.JobId);
        Timeslot       actualTimeslot = Timeslot.Create(e.StartTime, e.EndTime);

        job.Finish(actualTimeslot, e.Notes);
    }
        public void ThrowingArgumentExceptionIfDuplicatePresenterIdsWithDifferentAvailabilityCountsExist()
        {
            var presenter1 = Presenter.Create(1, new int[] { 2 });
            var presenter2 = Presenter.Create(2, new int[] { 2 });
            var presenter3 = Presenter.Create(1);

            var sessions = new SessionsCollection();

            var session1 = sessions.Add(1, 1, presenter1);
            var session2 = sessions.Add(2, 1, presenter2);
            var session3 = sessions.Add(3, 1, presenter3);

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));
            rooms.Add(Room.Create(2, 10));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1));
            timeslots.Add(Timeslot.Create(2));

            var engine = (null as IConferenceOptimizer).Create();

            Assert.Throws <ArgumentException>(() => engine.Process(sessions, rooms, timeslots));
        }
        public void NotFailIfTwoUnnamedSessionsHaveTheSameTimeslotUnavailability()
        {
            // This test exposes a bug that existed in a version
            // of the tool in early Oct 2018 where failing to add
            // a name caused a collision in naming constraints
            // if the same Timeslot is unavailable for multiple sessions
            var engine = (null as IConferenceOptimizer).Create();

            var sessions = new SessionsCollection();

            sessions.Add(1, null, Presenter.Create(1, new int[] { 2 }));
            sessions.Add(2, null, Presenter.Create(2, new int[] { 2 }));

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1));
            timeslots.Add(Timeslot.Create(2));
            timeslots.Add(Timeslot.Create(3));

            var assignments = engine.Process(sessions, rooms, timeslots);

            assignments.WriteSchedule();
        }
Ejemplo n.º 14
0
        public void Finish_Should_Finish_An_Existing_Job()
        {
            // arrange
            MaintenanceJobBuilder maintenanceJobBuilder = new MaintenanceJobBuilder();
            MaintenanceJob        sut = maintenanceJobBuilder
                                        .Build();

            DateTime actualStartTime = maintenanceJobBuilder.StartTime.AddMinutes(30);
            DateTime actualEndTime   = maintenanceJobBuilder.EndTime.AddMinutes(15);
            Timeslot actualTimeslot  = Timeslot.Create(actualStartTime, actualEndTime);
            string   notes           = $"Mechanic notes {maintenanceJobBuilder.JobId}";

            // act
            sut.Finish(actualTimeslot, notes);

            // assert
            Assert.Equal(maintenanceJobBuilder.JobId, sut.Id);
            Assert.Equal(maintenanceJobBuilder.StartTime, sut.PlannedTimeslot.StartTime);
            Assert.Equal(maintenanceJobBuilder.EndTime, sut.PlannedTimeslot.EndTime);
            Assert.Equal(maintenanceJobBuilder.CustomerBuilder.Id, sut.Customer.Id);
            Assert.Equal(maintenanceJobBuilder.CustomerBuilder.Name, sut.Customer.Name);
            Assert.Equal(maintenanceJobBuilder.CustomerBuilder.TelephoneNumber, sut.Customer.TelephoneNumber);
            Assert.Equal(maintenanceJobBuilder.VehicleBuilder.LicenseNumber, sut.Vehicle.Id);
            Assert.Equal(maintenanceJobBuilder.VehicleBuilder.Brand, sut.Vehicle.Brand);
            Assert.Equal(maintenanceJobBuilder.VehicleBuilder.Type, sut.Vehicle.Type);
            Assert.Equal(maintenanceJobBuilder.VehicleBuilder.OwnerId, sut.Vehicle.OwnerId);
            Assert.Equal(maintenanceJobBuilder.Description, sut.Description);
            Assert.Equal(actualTimeslot, sut.ActualTimeslot);
            Assert.Equal(notes, sut.Notes);
            Assert.Equal("Completed", sut.Status);
        }
        public void ReturningTheCorrectAssignmentIfTwoSpeakersAreAvailableForTwoOfTheThreeSlots()
        {
            var engine = (null as IConferenceOptimizer).Create();

            var sessions = new SessionsCollection();

            sessions.Add(1, null, Presenter.Create(1, new int[] { 2 })); // Not available for slot 2
            sessions.Add(2, null, Presenter.Create(2, new int[] { 2 })); // Not available for slot 2
            sessions.Add(3, null, Presenter.Create(3));                  // Available for all but must be assigned to slot 2

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1));
            timeslots.Add(Timeslot.Create(2));
            timeslots.Add(Timeslot.Create(3));

            var assignments     = engine.Process(sessions, rooms, timeslots);
            var checkAssignment = assignments.Where(a => a.SessionId == 3).Single();

            assignments.WriteSchedule();

            // Session 3 should have been assigned to slot 2
            Assert.Equal(2, checkAssignment.TimeslotId);
        }
        public void ReturningTheCorrectAssignmentIfOneSpeakerIsAvailableForOnlyOneSlot()
        {
            var engine = (null as IConferenceOptimizer).Create();

            var sessions = new SessionsCollection();

            sessions.Add(1, null, Presenter.Create(1));
            sessions.Add(2, null, Presenter.Create(2, new int[] { 2, 3 })); // Only available for slot 1
            sessions.Add(3, null, Presenter.Create(3));

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1));
            timeslots.Add(Timeslot.Create(2));
            timeslots.Add(Timeslot.Create(3));

            var assignments     = engine.Process(sessions, rooms, timeslots);
            var checkAssignment = assignments.Where(a => a.SessionId == 2).Single();

            assignments.WriteSchedule();

            // Session 2 should have been assigned to slot 1
            Assert.Equal(1, checkAssignment.TimeslotId);
        }
        public void ThrowingNoFeasibleSolutionIfAvailableTimeslotsForAMultiPresenterSessionDontIntersect()
        {
            // 2 presenters for one session where neither
            // is available to present when the other is available

            var presenter1 = Presenter.Create(1, new int[] { 2 });
            var presenter2 = Presenter.Create(2, new int[] { 1 });

            var sessions = new SessionsCollection();

            sessions.Add(1, null, presenter1, presenter2);

            var rooms = new List <Room>()
            {
                Room.Create(1, 10)
            };

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1));
            timeslots.Add(Timeslot.Create(2));

            var engine = (null as IConferenceOptimizer).Create();

            Assert.Throws <Exceptions.NoFeasibleSolutionsException>(() => engine.Process(sessions, rooms, timeslots));
        }
        public void FindingTheOnlyValidTimeslotForASessionWithChainedDependencies()
        {
            var engine = (null as IConferenceOptimizer).Create();

            var sessions = new SessionsCollection();

            var session1 = sessions.Add(1, null, Presenter.Create(1));
            var session2 = sessions.Add(2, null, Presenter.Create(3));
            var session3 = sessions.Add(3, null, Presenter.Create(1));
            var session4 = sessions.Add(4, null, Presenter.Create(2));
            var session5 = sessions.Add(5, null, Presenter.Create(2));
            var session6 = sessions.Add(6, null, Presenter.Create(2));

            session5.AddDependency(session6);
            session4.AddDependency(session5);

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1));
            rooms.Add(Room.Create(2));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1, 8.5));
            timeslots.Add(Timeslot.Create(2, 9.75));
            timeslots.Add(Timeslot.Create(3, 11.0));

            var assignments = engine.Process(sessions, rooms, timeslots);

            assignments.WriteSchedule();
            var testAssignment = assignments.Single(a => a.SessionId == 4);

            Assert.That(testAssignment.TimeslotId, Is.EqualTo(3), "Session 4 must be in the 3rd timeslot");
        }
        public void ThrowADuplicateEntityExceptionIfATimeslotBuilderIsAddedWithAnIdAlreadyAddedAsATimeslot()
        {
            int id     = Int32.MaxValue.GetRandom();
            var target = new TimeslotCollectionBuilder()
                         .Add(Timeslot.Create(id));

            Assert.Throws <DuplicateEntityException>(() => target.Add(new TimeslotBuilder(id)));
        }
Ejemplo n.º 20
0
        public void ReturnACollectionWithASingleTimeslotIfOneTimeslotAdded()
        {
            int id     = Int32.MaxValue.GetRandom();
            var actual = new TimeslotCollectionBuilder()
                         .Add(Timeslot.Create(id))
                         .Build();

            Assert.Single(actual);
        }
Ejemplo n.º 21
0
    private void Handle(MaintenanceJobPlanned e)
    {
        MaintenanceJob job             = new MaintenanceJob(e.JobId);
        Customer       customer        = new Customer(e.CustomerInfo.Id, e.CustomerInfo.Name, e.CustomerInfo.TelephoneNumber);
        LicenseNumber  licenseNumber   = LicenseNumber.Create(e.VehicleInfo.LicenseNumber);
        Vehicle        vehicle         = new Vehicle(licenseNumber, e.VehicleInfo.Brand, e.VehicleInfo.Type, customer.Id);
        Timeslot       plannedTimeslot = Timeslot.Create(e.StartTime, e.EndTime);

        job.Plan(plannedTimeslot, vehicle, customer, e.Description);
        Jobs.Add(job);
    }
Ejemplo n.º 22
0
        public void ReturnACollectionWithTwoTimeslotsIfATimeslotAndATimeslotBuilderAreAdded()
        {
            int id1    = Int32.MaxValue.GetRandom();
            int id2    = Int32.MaxValue.GetRandom();
            var actual = new TimeslotCollectionBuilder()
                         .Add(Timeslot.Create(id1))
                         .Add(new TimeslotBuilder(id2))
                         .Build();

            Assert.Equal(2, actual.Count());
        }
        private Teacher DaoToDomain(TeacherDao teacherDao)
        {
            var teacher = Teacher.Create(teacherDao.Id, teacherDao.Name);

            foreach (var tsDao in teacherDao.AvailableTimeslots)
            {
                var timeslot = Timeslot.Create(tsDao.Id, tsDao.StartTime, tsDao.EndTime, teacher);
                teacher.AvailableTimeslots.Add(timeslot);
            }
            return(teacher);
        }
Ejemplo n.º 24
0
    public void Creating_A_TimeSlot_With_A_StartTime_After_EndTime_Should_Throw_Exception()
    {
        // arrange
        DateTime startTime = DateTime.Now;
        DateTime endTime   = startTime.AddHours(-2);

        // act
        var thrownException =
            Assert.Throws <InvalidValueException>(() => Timeslot.Create(startTime, endTime));

        // assert
        Assert.Equal("The specified start-time may not be after the specified end-time.",
                     thrownException.Message);
    }
        public void ThrowingNoFeasibleSolutionsExceptionIfNoSessionsSupplied()
        {
            var sessions = new SessionsCollection();

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1));

            var engine = (null as IConferenceOptimizer).Create();

            var assignments = engine.Process(sessions, rooms, timeslots);
        }
        public void ThrowingArgumentNullExceptionIfRoomsIsNull()
        {
            var sessions = new SessionsCollection();

            sessions.Add(1, 1, Presenter.Create(1));

            IEnumerable <Room> rooms = null;

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1));

            var engine = (null as IConferenceOptimizer).Create();

            Assert.Throws <ArgumentNullException>(() => engine.Process(sessions, rooms, timeslots));
        }
        public void ThrowingArgumentExceptionIfNoRoomsSupplied()
        {
            var sessions = new SessionsCollection();

            sessions.Add(1, 1);

            var rooms = new List <Room>();

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1));

            var engine = (null as IConferenceOptimizer).Create();

            Assert.Throws <ArgumentException>(() => engine.Process(sessions, rooms, timeslots));
        }
        public void ThrowingArgumentNullExceptionIfSessionsIsNull()
        {
            IEnumerable <Session> sessions = null;

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1));

            var engine = (null as IConferenceOptimizer).Create();

            Assert.Throws <ArgumentNullException>(() => engine.Process(sessions, rooms, timeslots));
        }
        public void DistributingSessionsReasonablyAcrossTimeslotsWithNoDependencies()
        {
            var engine = (null as IConferenceOptimizer).Create();

            var sessions = new SessionsCollection();

            const int sessionCount = 12;

            for (int i = 0; i < sessionCount; i++)
            {
                sessions.Add(i, i, Presenter.Create(i));
            }

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));
            rooms.Add(Room.Create(2, 10));
            rooms.Add(Room.Create(3, 10));
            rooms.Add(Room.Create(4, 10));
            rooms.Add(Room.Create(5, 10));
            rooms.Add(Room.Create(6, 10));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1, 9.0));
            timeslots.Add(Timeslot.Create(2, 10.25));
            timeslots.Add(Timeslot.Create(3, 11.5));
            timeslots.Add(Timeslot.Create(4, 13.5));
            timeslots.Add(Timeslot.Create(5, 14.75));
            timeslots.Add(Timeslot.Create(6, 16.00));

            var assignments = engine.Process(sessions, rooms, timeslots);

            assignments.WriteSchedule();

            bool hasSurplus = false;

            for (int t = 0; t < timeslots.Count; t++)
            {
                hasSurplus = (hasSurplus || (assignments.Count(a => a.TimeslotId == t) > 2));
            }

            Assert.False(hasSurplus, "Sessions should be spread-out across timeslots");
        }
        public void ThrowingArgumentExceptionIfThereAreMoreSessionsThanSlotsAndRooms()
        {
            var engine = (null as IConferenceOptimizer).Create();

            var sessions = new SessionsCollection();

            sessions.Add(1, null, Presenter.Create(1));
            sessions.Add(2, null, Presenter.Create(2));

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1));

            Assert.Throws <ArgumentException>(() => engine.Process(sessions, rooms, timeslots));
        }