Example #1
0
        // Two plugins : 1, that requires 2 as MustExistAndRun
        // 1 is launched (SetAction("Started")) therefor, 2 is launched automatically
        // 1 is stopped (SetAction("Started")) 2 stays launched
        // 2 is stopped SetAction("stopped"). It should stop
        public void RefPluginLiveAction()
        {
            Guid id1 = new Guid("{4E69383E-044D-4786-9077-5F8E5B259793}");    //called 1 in the commentary
            Guid id2 = new Guid("{C24EE3EA-F078-4974-A346-B34208221B35}");    //called 2 in the commentary

            TestBase.CopyPluginToTestDir("ServiceC.Model.dll");
            TestBase.CopyPluginToTestDir("ServiceC.dll");
            TestBase.CopyPluginToTestDir("PluginNeedsServiceC.dll");
            PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true);

            PluginRunner.ConfigManager.UserConfiguration.LiveUserConfiguration.SetAction(id1, ConfigUserAction.Started);
            PluginRunner.Apply();
            Assert.That(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id1)), "Both should be launched as we launch 1 that needs 2");
            Assert.That(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id2)), "Both should be launched as we launch 1 that needs 2");

            PluginRunner.ConfigManager.UserConfiguration.LiveUserConfiguration.SetAction(id1, ConfigUserAction.Stopped);
            Assert.That(PluginRunner.IsDirty);
            PluginRunner.Apply();
            Assert.That(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id1)), Is.False, "The plugin should be stopped");
            Assert.That(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id2)), Is.True, "The plugin should still be running");

            PluginRunner.ConfigManager.UserConfiguration.LiveUserConfiguration.SetAction(id2, ConfigUserAction.Stopped);
            Assert.That(PluginRunner.IsDirty);
            PluginRunner.Apply();
            Assert.That(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id2)), Is.False, "The plugin should now be stopped");
        }
Example #2
0
        public void TestComplexInterfaces()
        {
            Guid id = new Guid("{12A9FCC0-ECDC-4049-8DBF-8961E49A9EDE}");

            TestBase.CopyPluginToTestDir("ServiceA.dll");

            PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true);

            Action afterStart = () => Assert.IsTrue(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id)));

            CheckStartStop(null, afterStart, null, null, id);
        }
Example #3
0
        /// <summary>
        /// Start a simple plugin With SystemConf set to AutomaticStart
        /// Change its pluginStatus to Manual
        /// Apply
        /// Check that is has not been stopped
        /// </summary>
        public void SimplePluginStatusSwitching()
        {
            Guid id = new Guid("{EEAEC976-2AFC-4A68-BFAD-68E169677D52}");

            TestBase.CopyPluginToTestDir("SimplePlugin.dll");
            PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true);

            PluginRunner.ConfigManager.SystemConfiguration.PluginsStatus.SetStatus(id, ConfigPluginStatus.AutomaticStart);
            PluginRunner.Apply();
            Assert.That(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id)));

            PluginRunner.ConfigManager.SystemConfiguration.PluginsStatus.SetStatus(id, ConfigPluginStatus.Manual);
            PluginRunner.Apply();
            Assert.That(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id)));
        }
Example #4
0
        /// <summary>
        /// Start stop a very simple plugin.
        /// Just check if the plugin can be started and stopped.
        /// </summary>
        public void SimplePlugin()
        {
            Guid id = new Guid("{EEAEC976-2AFC-4A68-BFAD-68E169677D52}");

            TestBase.CopyPluginToTestDir("SimplePlugin.dll");

            PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true);

            Action afterStart = () => Assert.IsTrue(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id)));
            Action afterStop  = () => Assert.IsTrue(!PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id)));

            CheckStartStop(null, afterStart, null, afterStop, id);

            // Second start/stop to try live user actions.
            CheckStartStop(null, afterStart, null, afterStop, id);
        }
Example #5
0
        /// <summary>
        /// Start a plugin that has a serviceRef With SystemConf set to  AutomaticStart
        /// Change its pluginStatus to Manual
        /// Apply
        /// Check that is has not been stopped
        /// </summary>
        public void RefPluginStatusSwitching()
        {
            Guid id = new Guid("{4E69383E-044D-4786-9077-5F8E5B259793}");

            TestBase.CopyPluginToTestDir("ServiceC.Model.dll");
            TestBase.CopyPluginToTestDir("ServiceC.dll");
            TestBase.CopyPluginToTestDir("PluginNeedsServiceC.dll");
            PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true);

            PluginRunner.ConfigManager.SystemConfiguration.PluginsStatus.SetStatus(id, ConfigPluginStatus.AutomaticStart);
            PluginRunner.Apply();
            Assert.That(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id)));

            PluginRunner.ConfigManager.SystemConfiguration.PluginsStatus.SetStatus(id, ConfigPluginStatus.Manual);
            PluginRunner.Apply();
            Assert.That(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id)));
        }
Example #6
0
        /// <summary>
        /// Just try to start BuggyPluginC that throw an exception in its start method.
        /// </summary>
        public void TryStartBuggyPlugin()
        {
            Guid id = new Guid("{FFB94881-4F59-4B97-B16E-CF3081A6E668}");

            TestBase.CopyPluginToTestDir("BuggyServiceC.dll");
            TestBase.CopyPluginToTestDir("ServiceC.Model.dll");

            PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true);

            Action check = () =>
            {
                // Check if the plugin is started, and if the plugin that implement the required service is started too.
                Assert.That(!PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id)));
            };

            CheckStartStop(null, check, null, check, false, true, id);
        }
Example #7
0
        /// <summary>
        /// Just try to start BuggyPluginC that throw an exception in its setup method.
        /// </summary>
        public void TrySetupBuggyPlugin()
        {
            Guid id = new Guid("{73FC9CFD-213C-4EC6-B002-452646B9D225}");

            TestBase.CopyPluginToTestDir("BuggyServiceC.dll");
            TestBase.CopyPluginToTestDir("ServiceC.Model.dll");

            PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true);

            Action check = () =>
            {
                // Check if the plugin is started, and if the plugin that implement the required service is started too.
                Assert.That(!PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id)));
            };

            CheckStartStop(null, check, null, check, false, true, id);
        }
Example #8
0
        /// <summary>
        /// Check if a plugin that implement a service can be started/stopped and if the service is available
        /// </summary>
        public void SimpleImplementService()
        {
            Guid id = new Guid("{E64F17D5-DCAB-4A07-8CEE-901A87D8295E}");

            TestBase.CopyPluginToTestDir("ServiceB.dll");

            PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true);

            Action afterStart = () =>
            {
                Assert.IsTrue(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id)));
                // Check that the service is available.
                //Assert.NotNull( PluginRunner.ServiceHost.GetRunningProxy( Type.GetType( "CK.Tests.Plugin.IServiceB, ServiceB, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", true ) ) );
            };
            Action afterStop = () => Assert.IsTrue(!PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id)));

            CheckStartStop(null, afterStart, null, afterStop, id);
        }