示例#1
0
        public void MainViewModel_AlarmReminderManagerRequestNotification_TriggersView_WhenCalled()
        {
            var alarm = FakeAlarm.GetAlarm(AlarmStatus.Missed);

            this.alarmReminderManager.OnRequestNotification += Raise.EventWith(new AlarmReminderEventArgs(string.Empty, string.Empty));

            this.view.ReceivedWithAnyArgs().ShowReminder(null, null);
        }
示例#2
0
        public void MainViewModel_AlarmServiceRemove_RemovesAlarmFromView()
        {
            var alarm = FakeAlarm.GetAlarm();

            this.alarmService.Remove(alarm);

            this.view.Received().RemoveAlarm(alarm);
        }
示例#3
0
        public void MainViewModel_AlarmServiceAdd_AddsAlarmToView()
        {
            var alarm = FakeAlarm.GetAlarm();

            this.alarmService.Add(alarm);

            this.view.Received().AddAlarm(alarm);
        }
示例#4
0
        public void FileAlarmRepository_Load_ReadsAlarmsFromDisk()
        {
            var alarm      = FakeAlarm.GetAlarm();
            var repository = this.CreateBlankRepository();

            repository.Load();

            this.sharedFileFactory.ReceivedWithAnyArgs().Read(null);
        }
示例#5
0
        public void FileAlarmRepository_Add_AddsItems()
        {
            var alarm      = FakeAlarm.GetAlarm();
            var repository = this.CreateBlankRepository();

            repository.Save(new [] { alarm });

            Assert.AreSame(alarm, this.serializeArgs.First());
        }
示例#6
0
        public void MainViewModel_AlarmServiceAdd_StartsAlarm_WhenRingingAlarmAdded()
        {
            var alarm = FakeAlarm.GetAlarm();

            alarm.IsRinging = true;

            this.alarmService.Add(alarm);

            this.view.Received().PlayAlarm();
        }
示例#7
0
        public void MainViewModel_AlarmStatusChange_PopsupView_ForMissedAlarms()
        {
            this.view.SetPopupOnAlarm(true);
            this.view.Visible = false;
            var alarm = FakeAlarm.GetAlarm(AlarmStatus.Missed);

            this.alarmService.TriggerAlarmStatusChange(alarm);

            this.view.Received().Show();
        }
示例#8
0
        public void MainViewModel_AlarmServiceRemove_StopsAlarm_WhenRingingAlarmRemoved()
        {
            var alarm = FakeAlarm.GetAlarm();

            alarm.IsRinging = true;
            this.alarmService.Add(alarm);

            this.alarmService.Remove(alarm);

            this.view.Received().StopAlarm();
        }
        public void AlarmReminderManager_TimerTrigger_DoesNotTriggerOnRequestNotification_WhenMissingAlarmsExist()
        {
            var hasReceivedEvent = false;

            service.Add(FakeAlarm.GetAlarm(AlarmStatus.Completed));
            manager.OnRequestNotification += (_, __) => hasReceivedEvent = true;

            timer.Elapsed += Raise.Event();

            Assert.IsFalse(hasReceivedEvent);
        }
示例#10
0
        public void MainViewModel_AlarmStatusChange_PlaysAlarm_WhenSoundEnabled()
        {
            this.view.SetSound(true);
            var alarm = FakeAlarm.GetAlarm();

            alarm.IsRinging = true;

            this.alarmService.TriggerAlarmStatusChange(alarm);

            this.view.Received().PlayAlarm();
        }
示例#11
0
        public void MainViewModel_AlarmStatusChange_DoesNotPlayAlarm_WhenSoundDisabled()
        {
            this.view.SetSound(false);
            var alarm = FakeAlarm.GetAlarm();

            alarm.IsRinging = true;

            this.alarmService.TriggerAlarmStatusChange(alarm);

            this.view.DidNotReceive().PlayAlarm();
        }
示例#12
0
        public void MainViewModel_SoundChange_DoesNotPlayAlarm_WhenNoRingingAlarms()
        {
            this.view.SetSound(false);
            var alarm = FakeAlarm.GetAlarm();

            this.alarmService.AddStorage(alarm);

            this.view.SetSound(true);

            this.view.DidNotReceive().PlayAlarm();
        }
示例#13
0
        public void MainViewModel_SoundChange_StopsAlarm_WhenSoundDisabled()
        {
            this.view.SetSound(true);
            var alarm = FakeAlarm.GetAlarm();

            alarm.IsRinging = true;
            this.alarmService.Add(alarm);

            this.view.SetSound(false);

            this.view.Received().StopAlarm();
        }
示例#14
0
        public void MainViewModel_SoundChange_PlaysAlarm_WhenSoundEnabled()
        {
            this.view.SetSound(false);
            var alarm = FakeAlarm.GetAlarm();

            alarm.IsRinging = true;
            this.alarmService.AddStorage(alarm);

            this.view.SetSound(true);

            this.view.Received().PlayAlarm();
        }
示例#15
0
        public void FileAlarmRepository_Add_AddsMultipleItems()
        {
            var alarm1 = FakeAlarm.GetAlarm();
            var alarm2 = FakeAlarm.GetAlarm();

            var repository = this.CreateBlankRepository();

            repository.Save(new [] { alarm1, alarm2 });

            Assert.AreSame(alarm1, this.serializeArgs.First());
            Assert.AreSame(alarm2, this.serializeArgs.Skip(1).First());
        }
示例#16
0
        public void MainViewModel_AlarmStatusChange_DoesNotPopupView_WhenAlreadyVisible()
        {
            this.view.SetPopupOnAlarm(true);
            this.view.Visible = true;
            var alarm = FakeAlarm.GetAlarm();

            alarm.IsRinging = true;

            this.alarmService.TriggerAlarmStatusChange(alarm);

            this.view.DidNotReceive().Show();
        }
示例#17
0
        public void FileAlarmRepository_List_ReturnsAlarms()
        {
            var alarm1 = FakeAlarm.GetAlarm();

            this.storage.Add(alarm1);
            var repository = this.CreateBlankRepository();

            var result = repository.Load();

            Assert.AreEqual(1, result.Count());
            Assert.AreSame(alarm1, result.First());
        }
示例#18
0
        public void MainViewModel_AlarmStatusChange_PopsupView_WhenEnabledAndViewHidden()
        {
            this.view.SetPopupOnAlarm(true);
            this.view.Visible = false;
            var alarm = FakeAlarm.GetAlarm();

            alarm.IsRinging = true;

            this.alarmService.TriggerAlarmStatusChange(alarm);

            this.view.Received().Show();
        }
示例#19
0
        public void MainViewModel_AlarmManagerWakeup_DoesNotRingAlarm_WhenNoRingingAlarms()
        {
            this.view.SetSmartAlarm(true);
            this.view.SetSound(true);
            var alarm = FakeAlarm.GetAlarm();

            this.alarmService.AddStorage(alarm);

            this.alarmManager.OnWakeup += Raise.Event();

            this.view.DidNotReceive().PlayAlarm();
        }
示例#20
0
        public void MainViewModel_AlarmManagerWakeup_RingsAlarm_WhenAnyRingingAlarm()
        {
            this.view.SetSmartAlarm(true);
            this.view.SetSound(true);
            var alarm = FakeAlarm.GetAlarm();

            alarm.IsRinging = true;
            this.alarmService.AddStorage(alarm);

            this.alarmManager.OnWakeup += Raise.Event();

            this.view.Received().PlayAlarm();
        }
示例#21
0
        public void MainViewModel_AlarmManagerSleep_StopsAlarm_WhenAnyRingingAlarms()
        {
            this.view.SetSmartAlarm(true);
            this.view.SetSound(true);
            var alarm = FakeAlarm.GetAlarm();

            alarm.IsRinging = true;
            this.alarmService.Add(alarm);

            this.alarmManager.OnSleep += Raise.Event();

            this.view.Received().StopAlarm();
        }
示例#22
0
        public void MainViewModel_AlarmManagerWakeup_PopupView_WhenAnyRingingAlarm()
        {
            this.view.SetSmartAlarm(true);
            this.view.SetPopupOnAlarm(true);
            this.view.Visible = false;
            var alarm = FakeAlarm.GetAlarm();

            alarm.IsRinging = true;
            this.alarmService.AddStorage(alarm);

            this.alarmManager.OnWakeup += Raise.Event();

            this.view.Received().Show();
        }
示例#23
0
        public void MainViewModel_ViewSmartAlarmDisable_EnablesSound_WhenViewIsNotMuted()
        {
            this.view.SetSmartAlarm(true);
            this.view.SetSound(true);
            var alarm = FakeAlarm.GetAlarm();

            alarm.IsRinging = true;
            this.alarmService.AddStorage(alarm);
            this.alarmManager.OnSleep += Raise.Event();

            this.view.SetSmartAlarm(false);

            this.view.Received().PlayAlarm();
        }
示例#24
0
        public void FileAlarmRepository_List_DoesNotReturnFilteredOutAlarms()
        {
            var alarm1 = FakeAlarm.GetAlarm();
            var alarm2 = FakeAlarm.GetAlarm();
            var filter = Substitute.For <IRepositoryFilter>();

            filter.Match(alarm1).Returns(true);
            filter.Match(alarm2).Returns(false);
            this.storage.Add(alarm1);
            this.storage.Add(alarm2);

            var repository = this.CreateBlankRepository(filter);

            var result = repository.Load();

            Assert.AreEqual(1, result.Count());
            Assert.AreSame(alarm1, result.First());
        }