Exemplo n.º 1
0
        public void ReadReminderTest()
        {
            using (var cs = new CherryService())
            {
                cs.PluginRepository.RegisterPlugin(new FakeReminderPlugin());
                cs.PluginRepository.RegisterPlugin(new PomodoroSensor());
                cs.PluginRepository.RegisterPlugin(new RemindersCorePlugin());
                cs.PluginRepository.RegisterPlugin(new ReminderPluginsRepository());
                cs.PluginRepository.RegisterPlugin(new FakeTimeProvider());
                cs.PluginRepository.RegisterPlugin(new FakeWindowsController());
                cs.PluginRepository.RegisterPlugin(new DatabaseController());

                var csr = new StringReader("<cherryTomato><config>" +
                                           "<reminders><reminder typeName=\"FakeReminder\" /></reminders>" +
                                           "</config></cherryTomato>");

                cs.InitializeCherryServiceEventsAndCommands();
                cs.PluginRepository.TieEvents();
                cs.LoadConfiguration(csr);

                var allReminders = cs.PluginRepository.CherryCommands["Get All Reminders"].Do(null)
                                   as IEnumerable <IReminder>;
                Assert.That(allReminders.FirstOrDefault().TypeName, Is.EqualTo("FakeReminder"));
            }
        }
        public void LoadConfigTest()
        {
            var dbFile       = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\cherrytomato\\database.sqlite";
            var ver          = new Version(Application.ProductVersion);
            var configString = "<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n" +
                               "<cherryTomato>\r\n" +
                               "  <hasRun />\r\n" +
                               "  <newestKnownVersion major=\"" + ver.Major + "\" minor=\"" + ver.Minor + "\" />\r\n" +
                               "  <databaseFile path=\"" + dbFile + "\" />\r\n" +
                               "  <config />\r\n" +
                               "</cherryTomato>";

            var reader = new StringReader(configString);

            using (var cs = new CherryService())
            {
                var vc = new VersionChecker();
                cs.PluginRepository.RegisterPlugin(new PomodoroSensor());
                cs.PluginRepository.RegisterPlugin(new FakeTimeProvider());
                cs.PluginRepository.RegisterPlugin(new DatabaseController());
                var fr = new FirstRunSensor();
                cs.PluginRepository.RegisterPlugin(fr);
                cs.PluginRepository.RegisterPlugin(vc);
                cs.InitializeCherryServiceEventsAndCommands();
                cs.PluginRepository.TieEvents();
                cs.LoadConfiguration(reader);
                Assert.AreEqual(true, fr.HasRun);
                Assert.AreEqual(ver.Major, vc.NewestKnownVersion.Major);
                Assert.AreEqual(ver.Minor, vc.NewestKnownVersion.Minor);
            }
        }
Exemplo n.º 3
0
        public void HasRunTest()
        {
            using (var cs = new CherryService())
            {
                cs.PluginRepository.RegisterPlugin(new PomodoroSensor());
                var fr = new FirstRunSensor();
                cs.PluginRepository.RegisterPlugin(fr);
                cs.PluginRepository.RegisterPlugin(new FakeTimeProvider());
                cs.PluginRepository.RegisterPlugin(new DatabaseController());
                cs.InitializeCherryServiceEventsAndCommands();
                cs.PluginRepository.TieEvents();
                var csr = new StringReader("<cherryTomato><hasRun /></cherryTomato>");
                cs.LoadConfiguration(csr);

                Assert.That(fr.HasRun, Is.True);
            }
        }