/// <summary> /// A plugin needs (MustExistTryStart) a IService{service} implemented by an other plugin. /// Check if the plugin that implement the service is auto started to fill the service reference. /// </summary> public void ServiceReference_IService_OptionalTryStart_Error() { #region Init Guid id = new Guid("{CDCE6413-038D-4020-A3E0-51FA755C5E72}"); TestBase.CopyPluginToTestDir("ServiceC.Model.dll"); TestBase.CopyPluginToTestDir("PluginNeedsServiceC.dll"); PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true); #endregion #region Asserts Action afterStart = () => { // Check if the plugin is started, and if the plugin that implement the required service is started too. Assert.IsTrue(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id))); }; Action afterStop = () => { // Check if the plugin is stopped. Assert.IsTrue(!PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id))); }; #endregion //Run! CheckStartStop(null, afterStart, null, afterStop, id); }
/// <summary> /// A plugin needs (MustExistTryStart) a IService{service} implemented by an other plugin. /// Check if the plugin that implement the service is auto started to fill the service reference. /// </summary> public void ServiceReference_IService_MustExist() { #region Init Guid id = new Guid("{973B4050-280F-43B0-A9E3-0C4DC9BC2C5F}"); TestBase.CopyPluginToTestDir("ServiceC.dll"); TestBase.CopyPluginToTestDir("ServiceC.Model.dll"); TestBase.CopyPluginToTestDir("PluginNeedsServiceC.dll"); PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true); #endregion #region Asserts Action afterStart = () => { // Check if the plugin is started, and if the plugin that implement the required service is started too. Assert.IsTrue(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id))); Assert.IsTrue(!PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(_implService))); }; Action afterStop = () => { // Check if the plugin is stopped. Assert.IsTrue(!PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id))); Assert.IsTrue(!PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(_implService))); }; #endregion //Run! CheckStartStop(null, afterStart, null, afterStop, id); }
/// <summary> /// Start the that needs the service. And then stop the service. Check that the plugin is stopped. /// </summary> public void ServiceReference_Normal_MustExistAndRun_ThenStopService() { Guid id = new Guid("{4E69383E-044D-4786-9077-5F8E5B259793}"); TestBase.CopyPluginToTestDir("ServiceC.dll"); TestBase.CopyPluginToTestDir("ServiceC.Model.dll"); TestBase.CopyPluginToTestDir("PluginNeedsServiceC.dll"); PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true); Action afterStart = () => { // Check if the plugin is started, and if the plugin that implement the required service is started too. Assert.IsTrue(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id))); Assert.IsTrue(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(_implService))); }; CheckStartAnotherStop(null, afterStart, null, afterStart, true, false, id, _implService); // Then we try to stop the plugin (the one that needs the service) _ctx.ConfigManager.UserConfiguration.LiveUserConfiguration.SetAction(id, Config.ConfigUserAction.Stopped); Assert.That(PluginRunner.Apply()); Assert.IsTrue(!PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id))); Assert.IsTrue(!PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(_implService))); }
/// <summary> /// A plugin needs (Optional) a IService{service} implemented by an other plugin. /// Check if the plugin that implement the service is auto started to fill the service reference. /// </summary> public void ServiceReference_IService_Optional_Error() { #region Init Guid id = new Guid("{FF896081-A15D-4A5C-8030-13544EF09673}"); TestBase.CopyPluginToTestDir("ServiceC.Model.dll"); TestBase.CopyPluginToTestDir("PluginNeedsServiceC.dll"); PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true); #endregion #region Asserts Action afterStart = () => { // Check if the plugin is started, and if the plugin that implement the required service is started too. Assert.IsTrue(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id))); }; Action afterStop = () => { // Check if the plugin is stopped. Assert.IsTrue(!PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id))); }; #endregion //Run! CheckStartStop(null, afterStart, null, afterStop, id); }
/// <summary> /// Start the that needs the service. And then stop the service. Check that the plugin is stopped. /// </summary> public void ServiceReference_IService_MustExistAndRun_ThenStopService() { Guid id = new Guid("{457E357D-102D-447D-89B8-DA9C849910C8}"); TestBase.CopyPluginToTestDir("ServiceC.dll"); TestBase.CopyPluginToTestDir("ServiceC.Model.dll"); TestBase.CopyPluginToTestDir("PluginNeedsServiceC.dll"); PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true); Action afterStart = () => { // Check if the plugin is started, and if the plugin that implement the required service is started too. Assert.IsTrue(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id))); Assert.IsTrue(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(_implService))); }; Action afterStop = () => { // Check if the plugin is stopped. Assert.IsTrue(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id))); Assert.IsTrue(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(_implService))); }; CheckStartAnotherStop(null, afterStart, null, afterStop, true, false, id, _implService); }
/// <summary> /// A plugin needs (MustExistTryStart) a IService{service} implemented by an other plugin. /// Check if the plugin that implement the service is auto started to fill the service reference. /// </summary> public void ServiceReference_IService_MustExistTryStart() { #region Init Guid id = new Guid("{9BBCFE92-7465-4B3B-88D0-3CEF1E2E5580}"); TestBase.CopyPluginToTestDir("ServiceC.dll"); TestBase.CopyPluginToTestDir("ServiceC.Model.dll"); TestBase.CopyPluginToTestDir("PluginNeedsServiceC.dll"); PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true); #endregion #region Asserts Action afterStart = () => { // Check if the plugin is started, and if the plugin that implement the required service is started too. Assert.IsTrue(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id))); // The plugin is available ... so we tried to start it. Assert.IsTrue(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(_implService))); }; Action afterStop = () => { // Check if the plugin is stopped. Assert.IsTrue(!PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id))); // The plugin that implements the service is still running, we don't care about machine resources yet. Assert.IsTrue(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(_implService))); }; #endregion //Run! CheckStartStop(null, afterStart, null, afterStop, id); }
public void LiveUserConfigOptional() { Guid id_plugin1 = new Guid("{12A9FCC0-ECDC-4049-8DBF-8961E49A9EDE}"); Guid id_plugin2 = new Guid("{E64F17D5-DCAB-4A07-8CEE-901A87D8295E}"); TestBase.CopyPluginToTestDir("ServiceA.dll"); TestBase.CopyPluginToTestDir("ServiceB.dll"); PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true); RequirementLayer layer = new RequirementLayer("MyLayer"); PluginRunner.Add(layer); Assert.That(!PluginRunner.IsDirty, "Not dirty because the layer is empty"); layer.PluginRequirements.AddOrSet(id_plugin1, RunningRequirement.Optional); Assert.That(!PluginRunner.IsDirty, "Still not dirty because plugin's are optional ... so we have nothing to change."); ConfigManager.UserConfiguration.LiveUserConfiguration.SetAction(id_plugin2, ConfigUserAction.None); Assert.That(!PluginRunner.IsDirty); Assert.IsTrue(PluginRunner.Remove(layer)); Assert.That(PluginRunner.RunnerRequirements.Count, Is.EqualTo(0)); Assert.That(!PluginRunner.IsDirty, "Not dirty because of the live user"); }
public void RediscoverImplementationOfAService() { Guid serviceC = new Guid("{C24EE3EA-F078-4974-A346-B34208221B35}"); Guid serviceC2 = new Guid("{1EC4980D-17F0-4DDC-86C6-631CDB69A6AD}"); TestBase.CopyPluginToTestDir("ServiceC.Model.dll"); // Service TestBase.CopyPluginToTestDir("ServiceC.dll"); // Implementation PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true); RequirementLayer layer = new RequirementLayer("RunnerTest"); layer.ServiceRequirements.AddOrSet("CK.Tests.Plugin.IServiceC, ServiceC.Model", RunningRequirement.MustExistAndRun); PluginRunner.RunnerRequirements.Add(layer); Assert.That(PluginRunner.Apply()); Assert.That(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(serviceC))); TestBase.CopyPluginToTestDir("ServiceC.Bis.dll"); // Second Implementation PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true); Assert.That(PluginRunner.IsDirty, Is.False); PluginRunner.ConfigManager.UserConfiguration.PluginsStatus.SetStatus(serviceC, ConfigPluginStatus.Disabled); Assert.That(PluginRunner.IsDirty); Assert.That(PluginRunner.Apply()); Assert.That(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(serviceC2))); }
void CheckStartAnotherStop(Action beforeStart, Action afterStart, Action beforeStop, Action afterStop, bool startSucceed, bool stopSucceed, Guid idToStart, Guid idToStop) { // Set a new user action --> start plugins _ctx.ConfigManager.UserConfiguration.LiveUserConfiguration.SetAction(idToStart, Config.ConfigUserAction.Started); if (beforeStart != null) { beforeStart(); } // So apply the change Assert.That(PluginRunner.Apply() == startSucceed); if (afterStart != null) { afterStart(); } // Set a new user action --> stop the plugin _ctx.ConfigManager.UserConfiguration.LiveUserConfiguration.SetAction(idToStop, Config.ConfigUserAction.Stopped); if (beforeStop != null) { beforeStop(); } // So apply the change Assert.IsTrue(PluginRunner.Apply() == stopSucceed); if (afterStop != null) { afterStop(); } }
// 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"); }
/// <summary> /// A plugin needs (MustExistTryStart) a IService{service} implemented by an other plugin. /// Check if the plugin that implement the service is auto started to fill the service reference. /// </summary> public void ServiceReference_IService_MustExistTryStart_Error() { #region Init Guid id = new Guid("{9BBCFE92-7465-4B3B-88D0-3CEF1E2E5580}"); TestBase.CopyPluginToTestDir("ServiceC.Model.dll"); TestBase.CopyPluginToTestDir("PluginNeedsServiceC.dll"); PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true); #endregion #region Asserts Action afterStart = () => { // Check if the plugin is started, and if the plugin that implement the required service is started too. Assert.IsTrue(!PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id))); }; Action afterStop = () => { // Check if the plugin is stopped. Assert.IsTrue(!PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id))); }; #endregion //Run! CheckStartStop(null, afterStart, null, afterStop, false, true, id); }
/// <summary> /// A plugin needs (MustExistTryStart) a service implemented by an other plugin. /// Check if the plugin that implement the service is auto started to fill the service reference. /// </summary> public void ServiceReference_Normal_OptionalTryStart() { #region Init Guid id = new Guid("{ABD53A18-4549-49B8-82C0-9977200F47E9}"); TestBase.CopyPluginToTestDir("ServiceC.dll"); TestBase.CopyPluginToTestDir("ServiceC.Model.dll"); TestBase.CopyPluginToTestDir("PluginNeedsServiceC.dll"); PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true); #endregion #region Asserts Action afterStart = () => { // Check if the plugin is started, and if the plugin that implement the required service is started too. Assert.IsTrue(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id))); Assert.IsTrue(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(_implService))); }; Action afterStop = () => { // Check if the plugin is stopped. Assert.IsTrue(!PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id))); Assert.IsTrue(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(_implService))); }; #endregion //Run! CheckStartStop(null, afterStart, null, afterStop, id); }
public void MergeRequirementsWithConfigDisabledAndLiveUserActions() { Guid id = new Guid("{12A9FCC0-ECDC-4049-8DBF-8961E49A9EDE}"); TestBase.CopyPluginToTestDir("ServiceA.dll"); PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true); RequirementLayer layer = new RequirementLayer("MyLayer"); layer.PluginRequirements.AddOrSet(id, RunningRequirement.MustExistTryStart); RequirementLayer layer2 = new RequirementLayer("MyLayer2"); layer2.PluginRequirements.AddOrSet(id, RunningRequirement.Optional); // the requirements needs a MustExistTryStart, we set the status of the plugin to Disabled _ctx.ConfigManager.UserConfiguration.PluginsStatus.SetStatus(id, ConfigPluginStatus.Disabled); // and we set the LiveUserAction to started _ctx.ConfigManager.UserConfiguration.LiveUserConfiguration.SetAction(id, ConfigUserAction.Started); PluginRunner.Add(layer); PluginRunner.Add(layer2); Assert.That(PluginRunner.RunnerRequirements.FinalRequirement(id) == SolvedConfigStatus.Disabled); }
public void RequirementLayerOptionals() { Guid id_plugin1 = new Guid("{12A9FCC0-ECDC-4049-8DBF-8961E49A9EDE}"); Guid id_plugin2 = new Guid("{E64F17D5-DCAB-4A07-8CEE-901A87D8295E}"); TestBase.CopyPluginToTestDir("ServiceA.dll"); TestBase.CopyPluginToTestDir("ServiceB.dll"); PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true); RequirementLayer layer = new RequirementLayer("MyLayer"); PluginRunner.Add(layer); Assert.That(!PluginRunner.IsDirty, "Not dirty because the layer is empty"); layer.PluginRequirements.AddOrSet(id_plugin1, RunningRequirement.Optional); layer.PluginRequirements.AddOrSet(id_plugin2, RunningRequirement.Optional); Assert.That(!PluginRunner.IsDirty, "Not dirty because plugin's are optional ... so we have nothing to change."); Assert.IsTrue(PluginRunner.Remove(layer)); Assert.That(PluginRunner.RunnerRequirements.Count, Is.EqualTo(0)); Assert.That(!PluginRunner.IsDirty, "Not dirty because the PluginRunner doesn't contains any requirement"); }
/// <summary> /// A plugin needs (MustExistTryStart) a service implemented by an other plugin. /// Check if the plugin that implement the service is auto started to fill the service reference. /// </summary> public void ServiceReference_Normal_MustExist_Error() { #region Init Guid id = new Guid("{317B5D34-BA84-4A15-92F4-4E791E737EF0}"); TestBase.CopyPluginToTestDir("ServiceC.Model.dll"); TestBase.CopyPluginToTestDir("PluginNeedsServiceC.dll"); PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true); #endregion #region Asserts Action afterStart = () => { // Check if the plugin is started, and if the plugin that implement the required service is started too. Assert.IsTrue(!PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id))); }; Action afterStop = () => { // Check if the plugin is stopped. Assert.IsTrue(!PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id))); }; #endregion //Run! CheckStartStop(null, afterStart, null, afterStop, false, true, id); }
/// <summary> /// A plugin needs (MustExistAndRun) a IService{service} implemented by an other plugin. /// Check if the plugin that implement the service is auto started to fill the service reference. /// </summary> public void ServiceReference_IService_MustExistAndRun() { Guid id = new Guid("{457E357D-102D-447D-89B8-DA9C849910C8}"); TestBase.CopyPluginToTestDir("ServiceC.dll"); TestBase.CopyPluginToTestDir("ServiceC.Model.dll"); TestBase.CopyPluginToTestDir("PluginNeedsServiceC.dll"); PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true); Action afterStart = () => { // Check if the plugin is started, and if the plugin that implement the required service is started too. Assert.IsTrue(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id))); Assert.IsTrue(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(_implService))); }; Action afterStop = () => { // Check if the plugin is stopped. Assert.IsTrue(!PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id))); // The plugin that implements the service is still running, we don't care about machine resources yet. Assert.IsTrue(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(_implService))); }; CheckStartStop(null, afterStart, null, afterStop, id); }
/// <summary> /// A plugin needs (Optional) a service implemented by an other plugin. /// Check if the plugin that implement the service is auto started to fill the service reference. /// </summary> public void ServiceReference_Normal_Optional_Error() { #region Init Guid id = new Guid("{C78FCB4F-6925-4587-AC98-DA0AE1A977D1}"); TestBase.CopyPluginToTestDir("ServiceC.Model.dll"); TestBase.CopyPluginToTestDir("PluginNeedsServiceC.dll"); PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true); #endregion #region Asserts Action afterStart = () => { // Check if the plugin is started, and if the plugin that implement the required service is started too. Assert.IsTrue(PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id))); }; Action afterStop = () => { // Check if the plugin is stopped. Assert.IsTrue(!PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id))); }; #endregion //Run! CheckStartStop(null, afterStart, null, afterStop, id); }
public static void Run(string[] args) { var pluginRunner = new PluginRunner <IStringGetter>( new PluginDirectoryAssemblyLocator(), isg => Console.WriteLine($"{isg.GetType()} => {isg.GetString()}")); pluginRunner.RunPlugins(); }
public PluggableViewModel(PluginRunner runner) : base() { PluggableProperties = new Dictionary<string, object>(); PluggableProperties["Brush"] = null; PluggableProperties["Order"] = -1; pluginRunner = runner; pluginRunner.AddVm(this); }
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); }
public void RequirementLayerService_AddFilled() { TestBase.CopyPluginToTestDir("ServiceA.dll"); PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true); RequirementLayer layer = new RequirementLayer("MyLayer"); layer.ServiceRequirements.AddOrSet("CK.Tests.Plugin.IServiceA, ServiceA, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", RunningRequirement.MustExistAndRun); PluginRunner.Add(layer); Assert.That(PluginRunner.IsDirty, "Should be dirty"); }
static void Main(string[] args) { var configurator = new HoustonSettingsConfigurator(new OnlineApiHoustonProperties()); var settings = configurator.Container.Get <IWebApiSettings>(); PluginRunner.Create(new OnlineApiPlugin(configurator)) .Listen(settings.Port) .WithProperties() .WithInfo() .WithLog(new VostokLogAdapter(configurator.Logger)) .Start(); }
public void RequirementLayerUnknownService() { PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true); RequirementLayer layer = new RequirementLayer("MyLayer"); PluginRunner.Add(layer); Assert.That(!PluginRunner.IsDirty, "Not dirty because the layer is empty"); layer.ServiceRequirements.AddOrSet("UnknownAQN!", RunningRequirement.Optional); Assert.That(!PluginRunner.IsDirty, "Should not be dirty because the service is unknown and the requirement is optional"); }
public void TestExecuteMethodReturnsWhenPluginPathIsMissingInJobDataMap() { // Arrange var pluginRunner = new PluginRunner(); IJobDetail jobDetail = new JobDetailImpl("jobsettings", typeof(IJob)); _mockJobExecutionContext.SetupGet(p => p.JobDetail).Returns(jobDetail); // Act pluginRunner.Execute(_mockJobExecutionContext.Object); // Assert Assert.False(File.Exists("FakeJobPlugin.txt")); }
public void SimpleWithoutDiscoverer() { Guid id = Guid.NewGuid(); RequirementLayer layer = new RequirementLayer("MyLayer"); PluginRunner.Add(layer); Assert.That(!PluginRunner.IsDirty, "Not dirty because the layer is empty"); layer.PluginRequirements.AddOrSet(id, RunningRequirement.MustExistAndRun); Assert.That(!PluginRunner.IsDirty, "Not dirty since the plugin is not found in the discoverer: it is Disabled."); PluginRunner.Remove(layer); Assert.That(!PluginRunner.IsDirty, "Not dirty because the PluginRunner doesn't contains any requirement"); }
/// <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))); }
public void TestExecuteMethodReturnsWhenPluginPathIsMissingInJobDataMap() { // Arrange var pluginRunner = new PluginRunner(); IJobDetail jobDetail = new JobDetailImpl("jobsettings", typeof(IJob)); _mockJobExecutionContext.SetupGet(p => p.JobDetail).Returns(jobDetail); // Act pluginRunner.Execute(_mockJobExecutionContext.Object); // Assert Assert.False(File.Exists("FakeJobPlugin.txt")); }
/// <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); }
private static void Main(string[] args) { SetupNlog(); var options = new SimulatorOptions(); if (Parser.Default.ParseArguments(args, options)) { // we cannot mark PluginDirectory option as Required=True, so we manually check here and show help if it is missing. if (string.IsNullOrWhiteSpace(options.PluginDirectory)) { Console.Write(options.GetUsage()); } else { // all seems good, execute the PluginRunner var pluginRunner = new PluginRunner(); pluginRunner.Run(options); } } }
public void TestExecuteMethodLoadsPluginFromPathAndExecutesIt() { // Arrange var pluginRunner = new PluginRunner(); string currentDirectory = Directory.GetCurrentDirectory(); IJobDetail jobDetail = new JobDetailImpl("jobsettings", typeof(IJob)); jobDetail.JobDataMap.Add("pluginPath", Path.Combine(currentDirectory, @"Resourses\R.Scheduler.FakeJobPlugin.dll")); _mockJobExecutionContext.SetupGet(p => p.JobDetail).Returns(jobDetail); // Act pluginRunner.Execute(_mockJobExecutionContext.Object); // Assert Assert.True(File.Exists("FakeJobPlugin.txt")); }
public void TestExecuteMethodLoadsPluginFromPathAndExecutesIt() { // Arrange var pluginRunner = new PluginRunner(); string currentDirectory = Directory.GetCurrentDirectory(); IJobDetail jobDetail = new JobDetailImpl("jobsettings", typeof(IJob)); jobDetail.JobDataMap.Add("pluginPath", Path.Combine(currentDirectory, @"Resourses\R.Scheduler.FakeJobPlugin.dll")); _mockJobExecutionContext.SetupGet(p => p.JobDetail).Returns(jobDetail); // Act pluginRunner.Execute(_mockJobExecutionContext.Object); // Assert Assert.True(File.Exists("FakeJobPlugin.txt")); }
/// <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))); }
/// <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); }
/// <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); }
public StepViewModel(IStepsService stepsService, PluginRunner runner) : base(runner) { this.stepsService = stepsService; }
public ProjectViewModel(IProjectsService projectsService, PluginRunner runner) : base(runner) { this.projectsService = projectsService; }
public ScenarioViewModel(IScenariosService scenariosService, PluginRunner runner) : base(runner) { this.scenariosService = scenariosService; }
public TestViewModel(ITestsService testsService, PluginRunner runner) : base(runner) { this.testsService = testsService; }