コード例 #1
0
        public void NormalScan()
        {
            var dir      = Util.GetSampleDirectory("ScanDataFilesTest");
            var registry = GetRegistry(dir);

            var fs       = new TestAddinFileSystemExtension();
            var scanData = fs.FileList;

            registry.RegisterExtension(fs);
            registry.Update();

            Assert.Contains(Path.Combine(dir, "App", "SimpleApp.addins"), scanData.OpenedFiles);
            Assert.Contains(Path.Combine(dir, "App", "SimpleAddin1.addin.xml"), scanData.OpenedFiles);
            Assert.Contains(Path.Combine(dir, "App", "SimpleApp.addin.xml"), scanData.OpenedFiles);
            Assert.Contains(Path.Combine(dir, "Addins", "SimpleAddin2.addin.xml"), scanData.OpenedFiles);
            Assert.Contains(Path.Combine(dir, "Addins", "SimpleAddin3.addin.xml"), scanData.OpenedFiles);
            Assert.Contains(Path.Combine(dir, "UserAddins", "SimpleAddin4.addin.xml"), scanData.OpenedFiles);

            var addins = registry.GetAddins().Select(a => a.Id).ToArray();

            Assert.AreEqual(4, addins.Length);
            Assert.Contains("SimpleApp.Ext1,0.1.0", addins);
            Assert.Contains("SimpleApp.Ext2,0.1.0", addins);
            Assert.Contains("SimpleApp.Ext3,0.1.0", addins);
            Assert.Contains("SimpleApp.Ext4,0.1.0", addins);
        }
コード例 #2
0
        public void GenerateAndLoadScanDataFiles()
        {
            var dir      = Util.GetSampleDirectory("ScanDataFilesTest");
            var registry = GetRegistry(dir);

            registry.GenerateAddinScanDataFiles(new ConsoleProgressStatus(true), recursive: true);

            // Check that data files have been generated

            Assert.IsTrue(File.Exists(Path.Combine(dir, "App", "dir.addindata")));
            Assert.IsTrue(File.Exists(Path.Combine(dir, "App", "SimpleAddin1.addin.xml.addindata")));
            Assert.IsTrue(File.Exists(Path.Combine(dir, "App", "SimpleApp.addin.xml.addindata")));
            Assert.IsTrue(File.Exists(Path.Combine(dir, "Addins", "SimpleAddin2.addin.xml.addindata")));
            Assert.IsTrue(File.Exists(Path.Combine(dir, "Addins", "SimpleAddin3.addin.xml.addindata")));

            // But not for user add-ins
            Assert.IsFalse(File.Exists(Path.Combine(dir, "UserAddins", "SimpleAddin4.addin.xml.addindata")));

            var fs       = new TestAddinFileSystemExtension();
            var scanData = fs.FileList;

            registry.RegisterExtension(fs);
            registry.Update();

            // Check that add-in files are not loaded, with the exception of user add-ins
            Assert.AreEqual(1, scanData.OpenedFiles.Count);
            Assert.Contains(Path.Combine(dir, "UserAddins", "SimpleAddin4.addin.xml"), scanData.OpenedFiles);

            var addins = registry.GetAddins().Select(a => a.Id).ToArray();

            Assert.AreEqual(4, addins.Length);
            Assert.Contains("SimpleApp.Ext1,0.1.0", addins);
            Assert.Contains("SimpleApp.Ext2,0.1.0", addins);
            Assert.Contains("SimpleApp.Ext3,0.1.0", addins);
            Assert.Contains("SimpleApp.Ext4,0.1.0", addins);

            AddinEngine engine = new AddinEngine();
        }