/// <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); }
/// <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); }
public void UserConfigPluginStatus() { Guid id_plugin1 = new Guid("{12A9FCC0-ECDC-4049-8DBF-8961E49A9EDE}"); TestBase.CopyPluginToTestDir("ServiceA.dll"); PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true); ConfigManager.UserConfiguration.PluginsStatus.SetStatus(id_plugin1, ConfigPluginStatus.Disabled); Assert.That(PluginRunner.IsDirty, "Even if the plugin is not running, the disabled configuration is a change."); ConfigManager.UserConfiguration.PluginsStatus.SetStatus(id_plugin1, ConfigPluginStatus.AutomaticStart); Assert.That(PluginRunner.IsDirty); Assert.That(PluginRunner.Apply()); Assert.That(!PluginRunner.IsDirty); ConfigManager.UserConfiguration.PluginsStatus.SetStatus(id_plugin1, ConfigPluginStatus.Disabled); Assert.That(PluginRunner.IsDirty); }
/// <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_Error() { #region Init Guid id = new Guid("{973B4050-280F-43B0-A9E3-0C4DC9BC2C5F}"); TestBase.CopyPluginToTestDir("ServiceC.Model.dll"); TestBase.CopyPluginToTestDir("PluginNeedsServiceC.dll"); PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true); #endregion #region Asserts Action after = () => { // 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))); }; #endregion //Run! CheckStartStop(null, after, null, after, 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_Error() { Guid id = new Guid("{457E357D-102D-447D-89B8-DA9C849910C8}"); 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))); }; Action afterStop = () => { // Check if the plugin is stopped. Assert.IsTrue(!PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id))); }; CheckStartStop(null, afterStart, null, afterStop, false, true, id); }
/// <summary> /// A plugin needs (MustExistAndRun) 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_MustExistAndRun_Error() { Guid id = new Guid("{4E69383E-044D-4786-9077-5F8E5B259793}"); 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))); }; Action afterStop = () => { // Check if the plugin is stopped. Assert.IsTrue(!PluginRunner.IsPluginRunning(PluginRunner.Discoverer.FindPlugin(id))); }; CheckStartStop(null, afterStart, null, afterStop, false, true, id); }
public void SimpleRequirementLayer() { Guid id = new Guid("{12A9FCC0-ECDC-4049-8DBF-8961E49A9EDE}"); TestBase.CopyPluginToTestDir("ServiceA.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, RunningRequirement.MustExistAndRun); Assert.That(PluginRunner.IsDirty, "Dirty because the plugin has been found in the discoverer."); 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"); }
public void UserAndSystemConfigCleared() { Guid id_plugin1 = new Guid("{12A9FCC0-ECDC-4049-8DBF-8961E49A9EDE}"); Guid id_plugin2 = new Guid("{E64F17D5-DCAB-4A07-8CEE-901A87D8295E}"); // Specific clear { TestBase.CopyPluginToTestDir("ServiceA.dll"); TestBase.CopyPluginToTestDir("ServiceB.dll"); PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true); _ctx.ConfigManager.UserConfiguration.PluginsStatus.SetStatus(id_plugin1, ConfigPluginStatus.AutomaticStart); _ctx.ConfigManager.SystemConfiguration.PluginsStatus.SetStatus(id_plugin2, ConfigPluginStatus.AutomaticStart); Assert.That(PluginRunner.IsDirty); _ctx.ConfigManager.UserConfiguration.PluginsStatus.Clear(id_plugin1); Assert.That(PluginRunner.IsDirty, "Still dirty because of the system configuration"); _ctx.ConfigManager.SystemConfiguration.PluginsStatus.Clear(id_plugin2); Assert.That(!PluginRunner.IsDirty); } // Global clear { TestBase.CopyPluginToTestDir("ServiceA.dll"); TestBase.CopyPluginToTestDir("ServiceB.dll"); PluginRunner.Discoverer.Discover(TestBase.TestFolderDir, true); _ctx.ConfigManager.UserConfiguration.PluginsStatus.SetStatus(id_plugin1, ConfigPluginStatus.AutomaticStart); _ctx.ConfigManager.SystemConfiguration.PluginsStatus.SetStatus(id_plugin2, ConfigPluginStatus.AutomaticStart); Assert.That(PluginRunner.IsDirty); _ctx.ConfigManager.UserConfiguration.PluginsStatus.Clear(); Assert.That(PluginRunner.IsDirty, "Still dirty because of the system configuration"); _ctx.ConfigManager.SystemConfiguration.PluginsStatus.Clear(); Assert.That(!PluginRunner.IsDirty); } }
public void MergeRequirementsWithConfig() { 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 AutomaticStart _ctx.ConfigManager.UserConfiguration.PluginsStatus.SetStatus(id, ConfigPluginStatus.AutomaticStart); PluginRunner.Add(layer); PluginRunner.Add(layer2); Assert.That(PluginRunner.RunnerRequirements.FinalRequirement(id) == SolvedConfigStatus.MustExistAndRun); }
public void MergeOnlyRequirements() { 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.MustExistAndRun); RequirementLayer layer2 = new RequirementLayer("MyLayer2"); layer2.PluginRequirements.AddOrSet(id, RunningRequirement.Optional); RequirementLayer layer3 = new RequirementLayer("MyLayer3"); layer3.PluginRequirements.AddOrSet(id, RunningRequirement.OptionalTryStart); PluginRunner.Add(layer); PluginRunner.Add(layer2); PluginRunner.Add(layer3); Assert.That(PluginRunner.RunnerRequirements.FinalRequirement(id) == SolvedConfigStatus.MustExistAndRun); }