Ejemplo n.º 1
0
        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");
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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");
        }
Ejemplo n.º 4
0
        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");
        }
Ejemplo n.º 5
0
        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");
        }
Ejemplo n.º 6
0
        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");
        }
Ejemplo n.º 7
0
        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");
        }
Ejemplo n.º 8
0
        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);
        }