Ejemplo n.º 1
0
        private void TestManuallyAdjustedSchedule2(
            Mock <ITalkScheduleService> scheduleService,
            MockDateTimeService dateTimeService,
            DateTime mtgStart,
            AdaptiveTimerService service)
        {
            var living1    = scheduleService.Object.GetTalkScheduleItem((int)TalkTypesAutoMode.LivingPart1);
            var study      = scheduleService.Object.GetTalkScheduleItem((int)TalkTypesAutoMode.CongBibleStudy);
            var concluding = scheduleService.Object.GetTalkScheduleItem((int)TalkTypesAutoMode.ConcludingComments);

            // add 5 mins to Study and remove 3 mins from Living1 and 2 minutes from concluding
            study.ModifiedDuration      = study.OriginalDuration.Add(TimeSpan.FromMinutes(5));
            living1.ModifiedDuration    = study.OriginalDuration.Add(-TimeSpan.FromMinutes(3));
            concluding.ModifiedDuration = study.OriginalDuration.Add(-TimeSpan.FromMinutes(2));

            dateTimeService.Set(mtgStart + living1.StartOffsetIntoMeeting);

            var adaptedDuration1 = service.CalculateAdaptedDuration(living1.Id);

            Assert.IsNull(adaptedDuration1);

            dateTimeService.Set(mtgStart + study.StartOffsetIntoMeeting + TimeSpan.FromMinutes(-3));

            var adaptedDuration2 = service.CalculateAdaptedDuration(study.Id);

            Assert.IsNull(adaptedDuration2);

            dateTimeService.Set(mtgStart + concluding.StartOffsetIntoMeeting + TimeSpan.FromMinutes(5));

            var adaptedDuration3 = service.CalculateAdaptedDuration(concluding.Id);

            Assert.IsNull(adaptedDuration3);
        }
Ejemplo n.º 2
0
        private void TestPerfectSchedule(
            Mock <ITalkScheduleService> scheduleService,
            MockDateTimeService dateTimeService,
            DateTime mtgStart,
            AdaptiveTimerService service)
        {
            var living1 = scheduleService.Object.GetTalkScheduleItem((int)TalkTypesAutoMode.LivingPart1);

            dateTimeService.Set(mtgStart + living1.StartOffsetIntoMeeting);

            var adaptedDuration1 = service.CalculateAdaptedDuration(living1.Id);

            Assert.IsNull(adaptedDuration1);

            var study = scheduleService.Object.GetTalkScheduleItem((int)TalkTypesAutoMode.CongBibleStudy);

            dateTimeService.Set(mtgStart + study.StartOffsetIntoMeeting);

            var adaptedDuration2 = service.CalculateAdaptedDuration(study.Id);

            Assert.IsNull(adaptedDuration2);

            var concluding = scheduleService.Object.GetTalkScheduleItem((int)TalkTypesAutoMode.ConcludingComments);

            dateTimeService.Set(mtgStart + concluding.StartOffsetIntoMeeting);

            var adaptedDuration3 = service.CalculateAdaptedDuration(concluding.Id);

            Assert.IsNull(adaptedDuration3);
        }
Ejemplo n.º 3
0
        private void TestLateSchedule2(
            Mock <ITalkScheduleService> scheduleService,
            MockDateTimeService dateTimeService,
            DateTime mtgStart,
            AdaptiveTimerService service)
        {
            var living1    = scheduleService.Object.GetTalkScheduleItem((int)TalkTypesAutoMode.LivingPart1);
            var concluding = scheduleService.Object.GetTalkScheduleItem((int)TalkTypesAutoMode.ConcludingComments);
            var study      = scheduleService.Object.GetTalkScheduleItem((int)TalkTypesAutoMode.CongBibleStudy);

            // 10 mins late starting the "Living" section.
            dateTimeService.Set(mtgStart + living1.StartOffsetIntoMeeting + TimeSpan.FromMinutes(10));

            var adaptedDuration1 = service.CalculateAdaptedDuration(living1.Id);

            Assert.IsNotNull(adaptedDuration1);
            AssertTimeSpansAboutEqual(adaptedDuration1.Value, new TimeSpan(0, 11, 52));
            living1.AdaptedDuration = adaptedDuration1;

            // at start of study we're only 5 mins behind
            dateTimeService.Set(mtgStart + study.StartOffsetIntoMeeting + TimeSpan.FromMinutes(5));

            // remove 5 mins from study and add to conclusion.
            study.ModifiedDuration      = study.OriginalDuration.Add(TimeSpan.FromMinutes(-5));
            concluding.ModifiedDuration = concluding.OriginalDuration.Add(TimeSpan.FromMinutes(5));

            // remaining meeting duration = 28 mins shared between study of 25 mins and conc of 8 mins (total 33 mins)
            // adapted duration of study = 21 mins 12 secs, conc = 6 mins 47 secs

            var adaptedDuration2 = service.CalculateAdaptedDuration(study.Id);

            Assert.IsNotNull(adaptedDuration2);
            AssertTimeSpansAboutEqual(adaptedDuration2.Value, new TimeSpan(0, 21, 12));
            study.AdaptedDuration = adaptedDuration2;

            dateTimeService.Set(mtgStart + study.StartOffsetIntoMeeting + TimeSpan.FromMinutes(5) + study.AdaptedDuration.Value);

            var adaptedDuration3 = service.CalculateAdaptedDuration(concluding.Id);

            Assert.IsNotNull(adaptedDuration3);
            AssertTimeSpansAboutEqual(adaptedDuration3.Value, new TimeSpan(0, 6, 47));
            concluding.AdaptedDuration = adaptedDuration3;
        }
Ejemplo n.º 4
0
        private void TestManuallyAdjustedSchedule4(
            Mock <ITalkScheduleService> scheduleService,
            MockDateTimeService dateTimeService,
            DateTime mtgStart,
            AdaptiveTimerService service)
        {
            var living1    = scheduleService.Object.GetTalkScheduleItem((int)TalkTypesAutoMode.LivingPart1);
            var study      = scheduleService.Object.GetTalkScheduleItem((int)TalkTypesAutoMode.CongBibleStudy);
            var concluding = scheduleService.Object.GetTalkScheduleItem((int)TalkTypesAutoMode.ConcludingComments);

            // take 5 mins from study but don't compensate elsewhere
            study.ModifiedDuration = study.OriginalDuration.Add(-TimeSpan.FromMinutes(5));

            dateTimeService.Set(mtgStart + living1.StartOffsetIntoMeeting);

            var adaptedDuration1 = service.CalculateAdaptedDuration(living1.Id);

            Assert.IsNotNull(adaptedDuration1);
            AssertTimeSpansAboutEqual(adaptedDuration1.Value, new TimeSpan(0, 16, 44));
            living1.AdaptedDuration = adaptedDuration1;

            dateTimeService.Set(mtgStart + living1.StartOffsetIntoMeeting + adaptedDuration1.Value);

            var adaptedDuration2 = service.CalculateAdaptedDuration(study.Id);

            Assert.IsNotNull(adaptedDuration2);
            AssertTimeSpansAboutEqual(adaptedDuration2.Value, new TimeSpan(0, 28, 12));
            study.AdaptedDuration = adaptedDuration2;

            dateTimeService.Set(mtgStart + study.StartOffsetIntoMeeting + adaptedDuration2.Value);

            var adaptedDuration3 = service.CalculateAdaptedDuration(concluding.Id);

            Assert.IsNotNull(adaptedDuration3);
            AssertTimeSpansAboutEqual(adaptedDuration3.Value, new TimeSpan(0, 4, 47));
            concluding.AdaptedDuration = adaptedDuration3;
        }
Ejemplo n.º 5
0
        private void TestEarlySchedule(
            Mock <ITalkScheduleService> scheduleService,
            MockDateTimeService dateTimeService,
            DateTime mtgStart,
            AdaptiveTimerService service)
        {
            // 10 mins early starting this section.
            var living1 = scheduleService.Object.GetTalkScheduleItem((int)TalkTypesAutoMode.LivingPart1);

            dateTimeService.Set(mtgStart + living1.StartOffsetIntoMeeting - TimeSpan.FromMinutes(10));

            var adaptedDuration1 = service.CalculateAdaptedDuration(living1.Id);

            Assert.IsNotNull(adaptedDuration1);
            AssertTimeSpansAboutEqual(adaptedDuration1.Value, new TimeSpan(0, 18, 7));
            living1.AdaptedDuration = adaptedDuration1;

            var study = scheduleService.Object.GetTalkScheduleItem((int)TalkTypesAutoMode.CongBibleStudy);

            dateTimeService.Set(mtgStart + study.StartOffsetIntoMeeting - TimeSpan.FromMinutes(5));

            var adaptedDuration2 = service.CalculateAdaptedDuration(study.Id);

            Assert.IsNotNull(adaptedDuration2);
            AssertTimeSpansAboutEqual(adaptedDuration2.Value, new TimeSpan(0, 34, 32));
            study.AdaptedDuration = adaptedDuration2;

            var concluding = scheduleService.Object.GetTalkScheduleItem((int)TalkTypesAutoMode.ConcludingComments);

            dateTimeService.Set(mtgStart + concluding.StartOffsetIntoMeeting - TimeSpan.FromMinutes(1));

            var adaptedDuration3 = service.CalculateAdaptedDuration(concluding.Id);

            Assert.IsNotNull(adaptedDuration3);
            AssertTimeSpansAboutEqual(adaptedDuration3.Value, new TimeSpan(0, 4, 0));
            concluding.AdaptedDuration = adaptedDuration3;
        }
Ejemplo n.º 6
0
        public void InitializeTests()
        {
            _items = GenerateTalkItems(_theDate);

            var options = MockOptions.Create();

            options.GenerateTimingReports = false;
            options.MidWeekAdaptiveMode   = AdaptiveMode.TwoWay;
            options.MidWeekOrWeekend      = MidWeekOrWeekend.MidWeek;
            options.OperatingMode         = OperatingMode.Automatic;

            Mock <IOptionsService> optionsService = new Mock <IOptionsService>();

            optionsService.Setup(o => o.Options).Returns(options);
            optionsService.Setup(x => x.GetAdaptiveMode()).Returns(options.MidWeekAdaptiveMode);

            _scheduleService = new Mock <ITalkScheduleService>();
            _scheduleService.Setup(x => x.GetTalkScheduleItems()).Returns(_items);
            _scheduleService.Setup(x => x.GetTalkScheduleItem(It.IsAny <int>())).Returns((int id) => _items.Single(y => y.Id == id));

            _dateTimeService = new MockDateTimeService();
            _mtgStart        = _theDate + TimeSpan.FromHours(19); // 7pm
            _dateTimeService.Set(_mtgStart);

            _adaptiveTimerService = new AdaptiveTimerService(
                optionsService.Object, _scheduleService.Object, _dateTimeService);

            _adaptiveTimerService.SetMeetingStartTimeForTesting(_dateTimeService.UtcNow());

            // complete most of the timers...
            foreach (var item in _items)
            {
                if (item.Id == (int)TalkTypesAutoMode.LivingPart1)
                {
                    break;
                }

                // each item exactly on time
                item.CompletedTimeSecs = (int)item.ActualDuration.TotalSeconds;
            }
        }
Ejemplo n.º 7
0
        public void TestOperatorViewStartStop()
        {
            const int TalkIdStart = 500;
            const int NumTalks    = 3;

            var options = MockOptions.Create();

            options.GenerateTimingReports = false;
            options.MidWeekAdaptiveMode   = AdaptiveMode.TwoWay;
            options.MidWeekOrWeekend      = MidWeekOrWeekend.MidWeek;
            options.OperatingMode         = OperatingMode.Automatic;

            var optionsService = new Mock <IOptionsService>();

            optionsService.Setup(o => o.Options).Returns(options);
            optionsService.Setup(x => x.GetAdaptiveMode()).Returns(options.MidWeekAdaptiveMode);

            var timerService                     = new Mock <ITalkTimerService>();
            var adaptiveTimerService             = new Mock <IAdaptiveTimerService>();
            ITalkScheduleService scheduleService = new MockTalksScheduleService(TalkIdStart, NumTalks);
            var bellService        = new Mock <IBellService>();
            var commandLineService = new Mock <ICommandLineService>();
            var timingDataService  = new Mock <ILocalTimingDataStoreService>();
            var snackbarService    = new Mock <ISnackbarService>();
            var dateTimeService    = new MockDateTimeService();
            IQueryWeekendService queryWeekendService = new QueryWeekendService();

            dateTimeService.Set(new DateTime(2019, 11, 28) + TimeSpan.FromHours(19));

            var vm = new OperatorPageViewModel(
                timerService.Object,
                scheduleService,
                adaptiveTimerService.Object,
                optionsService.Object,
                commandLineService.Object,
                bellService.Object,
                timingDataService.Object,
                snackbarService.Object,
                dateTimeService,
                queryWeekendService);

            Assert.IsFalse(vm.IsRunning);
            Assert.IsFalse(vm.IsManualMode);

            for (var n = 0; n < NumTalks; ++n)
            {
                var talkId = TalkIdStart + n;
                Assert.IsTrue(vm.TalkId == talkId);

                var talk = scheduleService.GetTalkScheduleItem(talkId);
                Assert.IsNotNull(talk);
                Assert.AreEqual(vm.CurrentTimerValueString, TimeFormatter.FormatTimerDisplayString(talk.GetPlannedDurationSeconds()));

                vm.StartCommand.Execute(null);
                Assert.IsTrue(vm.IsRunning);

                Assert.IsTrue(vm.TalkId == TalkIdStart + n);

                vm.StopCommand.Execute(null);
                Assert.IsFalse(vm.IsRunning);

                Assert.IsTrue(vm.TalkId == (n == NumTalks - 1 ? 0 : TalkIdStart + n + 1));
            }
        }