Exemple #1
0
        public void CreatePackageDepVersions()
        {
            var tmp  = Path.GetTempFileName();
            var tmp2 = Path.GetTempFileName();

            Directory.Move("Packages", "Packages2");
            try
            {
                {
                    PackageDef def = new PackageDef();
                    def.Name     = "test";
                    def.InfoLink = "a";
                    def.Date     = DateTime.Today;

                    def.AddFile(tmp);

                    var bs = PluginManager.GetSearcher().Assemblies.First(asm => asm.Name == "OpenTap.Plugins.BasicSteps");
                    def.Files[0].DependentAssemblies.Add(bs);

                    var searcher = new PluginSearcher();
                    searcher.Search(Directory.GetCurrentDirectory());
                    List <AssemblyData> assemblies = searcher.Assemblies.ToList();
                    def.findDependencies(new List <string>(), assemblies);

                    Assert.AreEqual(0, def.Dependencies.Count);
                    Assert.AreNotEqual(0, def.Files.Count);
                }

                {
                    PackageDef def = new PackageDef();

                    def.AddFile(tmp);

                    var bs = PluginManager.GetSearcher().Assemblies.First(asm => asm.Name == "OpenTap.Plugins.BasicSteps");
                    def.Files[0].DependentAssemblies.Add(bs);

                    var searcher = new PluginSearcher();
                    searcher.Search(Directory.GetCurrentDirectory());
                    List <AssemblyData> assemblies = searcher.Assemblies.ToList();
                    def.findDependencies(new List <string> {
                        "OpenTap"
                    }, assemblies);

                    Assert.AreEqual(0, def.Dependencies.Count);
                    Assert.AreNotEqual(1, def.Files.Count);
                }
            }
            finally
            {
                if (Directory.Exists("Packages"))
                {
                    Directory.Delete("Packages", true);
                }
                Directory.Move("Packages2", "Packages");
            }
        }
Exemple #2
0
        public void CreatePackageDepReuse()
        {
            if (Directory.Exists("Packages2"))
            {
                Directory.Delete("Packages2", true);
            }

            Directory.Move("Packages", "Packages2");
            File.Copy("Packages2/DependencyTest.dll", "DependencyTest.dll", true);

            try
            {
                Directory.CreateDirectory("Packages");

                {
                    PackageDef def = new PackageDef()
                    {
                        Name = "pkg1", Version = SemanticVersion.Parse("1.2")
                    };
                    def.AddFile("OpenTap.dll");
                    Directory.CreateDirectory("Packages/pkg1");
                    using (var f = File.OpenWrite("Packages/pkg1/package.xml")) def.SaveTo(f);
                }

                {
                    PackageDef def = new PackageDef()
                    {
                        Name = "gui", Version = SemanticVersion.Parse("1.2")
                    };
                    def.AddFile("Keysight.OpenTap.Wpf.dll");
                    Directory.CreateDirectory("Packages/gui");
                    using (var f = File.OpenWrite("Packages/gui/package.xml")) def.SaveTo(f);
                }

                {
                    PackageDef def = new PackageDef()
                    {
                        Name = "rv", Version = SemanticVersion.Parse("1.2")
                    };
                    def.AddFile("Keysight.OpenTap.Wpf.dll");
                    Directory.CreateDirectory("Packages/rv");
                    using (var f = File.OpenWrite("Packages/rv/package.xml")) def.SaveTo(f);
                }

                {
                    PackageDef def = new PackageDef();
                    def.Name     = "test";
                    def.InfoLink = "a";
                    def.Date     = DateTime.Today;

                    def.Dependencies.Add(new PackageDependency("rv", VersionSpecifier.Parse("1.2")));

                    def.AddFile("DependencyTest.dll");
                    def.Files[0].DependentAssemblies.AddRange(PluginManager.GetSearcher().Assemblies.First(f => f.Name == "DependencyTest").References);

                    var searcher = new PluginSearcher();
                    searcher.Search(Directory.GetCurrentDirectory());
                    List <AssemblyData> assemblies = searcher.Assemblies.ToList();
                    def.findDependencies(new List <string>(), assemblies);

                    //Assert.AreEqual(3, def.Dependencies.Count);
                    Assert.IsTrue(def.Dependencies.Any(d => d.Name == "rv"));
                    Assert.IsTrue(def.Dependencies.Any(d => d.Name == "pkg1"));
                }

                {
                    PackageDef def = new PackageDef();
                    def.Name     = "test";
                    def.InfoLink = "a";
                    def.Date     = DateTime.Today;

                    def.Dependencies.Add(new PackageDependency("gui", VersionSpecifier.Parse("1.2")));

                    def.AddFile("DependencyTest.dll");
                    def.Files[0].DependentAssemblies.AddRange(PluginManager.GetSearcher().Assemblies.First(f => f.Name == "DependencyTest").References);

                    var searcher = new PluginSearcher();
                    searcher.Search(Directory.GetCurrentDirectory());
                    List <AssemblyData> assemblies = searcher.Assemblies.ToList();
                    def.findDependencies(new List <string>(), assemblies);

                    //Assert.AreEqual(2, def.Dependencies.Count);
                    Assert.IsTrue(def.Dependencies.Any(d => d.Name == "gui"));
                    Assert.IsTrue(def.Dependencies.Any(d => d.Name == "pkg1"));
                }
            }
            finally
            {
                if (Directory.Exists("Packages"))
                {
                    Directory.Delete("Packages", true);
                }
                Directory.Move("Packages2", "Packages");
            }
        }