public void PomodoroAllEventsTest() { var cs = new CherryService(); var ftp = new FakeTimeProvider { Now = new DateTime(2009, 05, 13) }; var ps = new PomodoroSensor(); cs.PluginRepository.RegisterPlugin(ftp); cs.PluginRepository.RegisterPlugin(ps); cs.PluginRepository.RegisterPlugin(new DatabaseController()); cs.InitializeCherryServiceEventsAndCommands(); cs.PluginRepository.TieEvents(); var eventChecker = new EventFiredChecker(cs); eventChecker.WaitFor("Pomodoro Started", "Pomodoro Finishing", "Pomodoro Finished"); Assert.IsTrue((bool)eventChecker.InvokeCommand("Start Pomodoro", null)); eventChecker.AssertFired("Pomodoro Started"); eventChecker.AssertNotFired("Pomodoro Finishing", "Pomodoro Finished"); ftp.AdvanceMinutes(25); Assert.IsTrue((bool)eventChecker.InvokeCommand("Stop Pomodoro", null)); eventChecker.AssertFired("Pomodoro Finishing", "Pomodoro Finished"); eventChecker.Reset(); Assert.IsTrue((bool)eventChecker.InvokeCommand("Start Pomodoro", null)); eventChecker.AssertFired("Pomodoro Started"); eventChecker.AssertNotFired("Pomodoro Finishing", "Pomodoro Finished"); ftp.AdvanceMinutes(25); Assert.IsTrue((bool)eventChecker.InvokeCommand("Void Pomodoro", null)); eventChecker.AssertFired("Pomodoro Finishing", "Pomodoro Finished"); }
public void PomodoroTest() { using (var cs = new CherryService()) { var ps = new PomodoroSensor(); cs.PluginRepository.RegisterPlugin(ps); var tp = new FakeTimeProvider(); cs.PluginRepository.RegisterPlugin(tp); cs.PluginRepository.RegisterPlugin(new FakeWindowsController()); cs.PluginRepository.RegisterPlugin(new FakeSettingsController()); var ic = new IconController(); cs.PluginRepository.RegisterPlugin(ic); cs.PluginRepository.RegisterPlugin(new DatabaseController()); var im = new FakeImController(); cs.PluginRepository.RegisterPlugin(im); cs.InitializeCherryServiceEventsAndCommands(); cs.PluginRepository.TieEvents(); cs.PluginRepository.CherryCommands["Start Pomodoro"].Do(null); ic.UpdateToolTipTextMessage(); Assert.True(ps.CurrentlyInPomodoro); Assert.That(ps.GetCurrentStatusData().Remaining.Minutes, Is.EqualTo(25)); Assert.That(im.InPomodoro); Assert.That(ps.GetCurrentStatusData().MinutesLeft, Is.EqualTo(25)); Assert.IsTrue(ic.ToolTipText.StartsWith("In pomodoro. 25 minutes left")); tp.AdvanceMinutes(3); ic.UpdateToolTipTextMessage(); Assert.True(ps.CurrentlyInPomodoro); Assert.That(ps.GetCurrentStatusData().Remaining.Minutes, Is.EqualTo(22)); Assert.That(ps.GetCurrentStatusData().MinutesLeft, Is.EqualTo(22)); Assert.IsTrue(ic.ToolTipText.StartsWith("In pomodoro. 22 minutes left")); tp.AdvanceMinutes(22); ps.StopPomodoroInternal(true); Assert.That(ic.ToolTipText, Is.EqualTo("Pomodoro completed")); // Poll eniough times to make icon controller stop flashing. ic.StopFlashing(); tp.AdvanceMinutes(10); ic.UpdateToolTipTextMessage(); //Assert.That(cs.GetTimeSinceLastPomodoro().TotalMinutes, Is.EqualTo(10)); Assert.That(im.InPomodoro, Is.False); Assert.IsTrue(ic.ToolTipText.StartsWith("Out of pomodoro for 10 minutes")); tp.AdvanceMinutes(59); ic.UpdateToolTipTextMessage(); Assert.IsTrue(ic.ToolTipText.StartsWith("Out of pomodoro for 1 hour")); } }
public void SimpleTest() { var cs = new CherryService(); var ftp = new FakeTimeProvider { Now = new DateTime(2009, 05, 13) }; var ps = new PomodoroSensor(); cs.PluginRepository.RegisterPlugin(ftp); cs.PluginRepository.RegisterPlugin(ps); cs.PluginRepository.RegisterPlugin(new DatabaseController()); cs.InitializeCherryServiceEventsAndCommands(); cs.PluginRepository.TieEvents(); ps.ConnectToDatabase(dbCon); // Create a couple of fake pomodoros.. One for yesterday and two for today. dbCon.ExecuteNonQuery( "insert into PomodoroRegistrations (TimeStamp, Duration, Evaluation) values (@p1, @p2, @p3);", new DateTime(2009, 05, 12), new TimeSpan(0, 0, 25, 0).Ticks, 5); dbCon.ExecuteNonQuery( "insert into PomodoroRegistrations (TimeStamp, Duration, Evaluation) values (@p1, @p2, @p3);", new DateTime(2009, 05, 13, 12, 30, 0), new TimeSpan(0, 0, 25, 0).Ticks, 5); dbCon.ExecuteNonQuery( "insert into PomodoroRegistrations (TimeStamp, Duration, Evaluation) values (@p1, @p2, @p3);", new DateTime(2009, 05, 13, 13, 30, 0), new TimeSpan(0, 0, 25, 0).Ticks, 5); // And connect again to load those into memory ps.ConnectToDatabase(dbCon); // There are two pomodoros for today. 5 points each. Assert.That(ps.TodayProductivity.Pomodoros, Is.EqualTo(2)); Assert.That(ps.TodayProductivity.Rating, Is.EqualTo(10)); ps.StartPomodoroInternal(); ftp.AdvanceMinutes(10); ps.StopPomodoroInternal(false); }
public void ManualFlashTest() { var cs = new CherryService(); var tp = new TimeProvider(); var ps = new PomodoroSensor(); var ic = new IconController(); var icn = new CherryTomato.Reminders.SystrayIconNotifier.IconNotifier(); cs.PluginRepository.RegisterPlugin(tp); cs.PluginRepository.RegisterPlugin(ps); cs.PluginRepository.RegisterPlugin(ic); cs.PluginRepository.RegisterPlugin(icn); cs.InitializeCherryServiceEventsAndCommands(); cs.PluginRepository.TieEvents(); icn.Notify(new IconNotification { FlashCount = 10, FlashIconPath = "res://pomodoro.ico", NotificationText = "Flash test" }); Assert.That(MessageBox.Show("Did the icon flash?", "Manual assert", MessageBoxButtons.YesNo), Is.EqualTo(DialogResult.Yes)); cs.Dispose(); }
public void SimpleTest() { var fpaws = new FakeProcessAndWindowSpy(); var ftp = new FakeTimeProvider {Now = new DateTime(2009, 05, 13)}; var ats = new CherryTomato.ActiveTaskSensor.ActiveTaskSensor(fpaws); var cs = new CherryService(); var ps = new PomodoroSensor(); cs.PluginRepository.RegisterPlugin(ftp); cs.PluginRepository.RegisterPlugin(ats); cs.PluginRepository.RegisterPlugin(ps); cs.PluginRepository.RegisterPlugin(new DatabaseController()); cs.InitializeCherryServiceEventsAndCommands(); cs.PluginRepository.TieEvents(); fpaws.ActiveTask = new TaskRegistration { TaskName = "Task1", ProcessName = "Task1" }; ps.StartPomodoroInternal(); fpaws.ActiveTask = new TaskRegistration { TaskName = "Task1", ProcessName = "Task1" }; ats.CountActiveTask(); ftp.AdvanceMinutes(10); ats.CountActiveTask(); fpaws.ActiveTask = new TaskRegistration { TaskName = "Task2", ProcessName = "Task2" }; ats.CountActiveTask(); }