Exemplo n.º 1
0
        public void TestPlugin_OrphanImport_Sharing()
        {
            //Setup the load module we want to test (with plugin parent)
            var fi = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "Blah2." + PackPluginRunner.PluginPackageSuffix));

            File.WriteAllBytes(fi.FullName, new byte[] { 0x1, 0x2 });

            var fi2 = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "Blah2." + PackPluginRunner.PluginPackageSuffix));

            File.WriteAllBytes(fi2.FullName, new byte[] { 0x1, 0x2 });

            var fi3 = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "Blah3." + PackPluginRunner.PluginPackageSuffix));

            File.WriteAllBytes(fi3.FullName, new byte[] { 0x3, 0x4 });

            Core.Curation.Data.Plugin p = new Core.Curation.Data.Plugin(Repository, fi, new Version(1, 1, 1), new Version(1, 1, 1, 1));
            var lma  = new LoadModuleAssembly(Repository, fi2, p);
            var lma2 = new LoadModuleAssembly(Repository, fi3, p);

            //gather dependencies of the plugin (plugin[0] + lma[1])
            Gatherer     g    = new Gatherer(RepositoryLocator);
            ShareManager sm   = new ShareManager(RepositoryLocator);
            var          list = g.GatherDependencies(p).ToShareDefinitionWithChildren(sm);

            //Delete export definitions
            foreach (var e in Repository.GetAllObjects <ObjectExport>())
            {
                e.DeleteInDatabase();
            }

            //and delete pluing (CASCADE deletes lma too)
            p.DeleteInDatabase();

            //import them
            var created = sm.ImportSharedObject(list).ToArray();

            //There should be 3
            Assert.AreEqual(3, created.Count());

            Assert.AreEqual(3, Repository.GetAllObjects <ObjectImport>().Count());

            lma2 = (LoadModuleAssembly)created[2];

            //now delete lma2 only
            lma2.DeleteInDatabase();

            Assert.AreEqual(2, Repository.GetAllObjects <ObjectImport>().Count());

            //import them
            var created2 = sm.ImportSharedObject(list);

            //There should still be 3
            Assert.AreEqual(3, created2.Count());
        }
Exemplo n.º 2
0
        public void GatherAndShare_Plugin_Test()
        {
            var f1 = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "Imaginary1" + PackPluginRunner.PluginPackageSuffix));

            File.WriteAllBytes(f1.FullName, new byte[] { 0x1, 0x2 });

            var plugin = new Core.Curation.Data.Plugin(CatalogueRepository, new FileInfo("Imaginary" + PackPluginRunner.PluginPackageSuffix), new System.Version(1, 1, 1), new System.Version(1, 1, 1));
            var lma1   = new LoadModuleAssembly(CatalogueRepository, f1, plugin);

            Assert.AreEqual(lma1.Plugin_ID, plugin.ID);

            Gatherer g = new Gatherer(RepositoryLocator);

            Assert.IsTrue(g.CanGatherDependencies(plugin));

            var gObj = g.GatherDependencies(plugin);

            //root should be the server
            Assert.AreEqual(gObj.Object, plugin);
            Assert.IsTrue(gObj.Children.Any(d => d.Object.Equals(lma1)));
        }