Ejemplo n.º 1
0
        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"));
            }
        }