public void FileRepositoryManagerTest() { string pkgContent = @"<?xml version=""1.0"" encoding=""utf-8""?> <Package Name=""BasicSteps"" xmlns=""http://keysight.com/schemas/TAP/Package"" OS=""Linux,Windows""> <Files> <File Path=""__BASICSTEPS_DLL__""> <UseVersion/> </File> </Files> </Package> ".Replace("__BASICSTEPS_DLL__", Path.GetFileName(typeof(DelayStep).Assembly.Location)); string pkgName = "BasicSteps.xml"; try { if (File.Exists(pkgName)) { File.Delete(pkgName); } File.WriteAllText(pkgName, pkgContent); string installDir = Path.GetDirectoryName(typeof(Package.PackageDef).Assembly.Location); var pkg = PackageDefExt.FromInputXml(pkgName, installDir); CollectionAssert.IsNotEmpty(pkg.Dependencies, "Package has no dependencies."); //Assert.AreEqual("OpenTAP", pkg.Dependencies.First().Name); pkg.CreatePackage("BasicSteps.TapPackage"); List <IPackageRepository> repositories = new List <IPackageRepository>() { new FilePackageRepository(installDir) }; var packages = PackageRepositoryHelpers.GetPackagesFromAllRepos(repositories, new PackageSpecifier()); CollectionAssert.IsNotEmpty(packages, "Repository does not list any packages."); Assert.IsTrue(packages.Any(p => p.Name == "BasicSteps")); var depVersion = pkg.Dependencies.First().Version; var version = new SemanticVersion(depVersion.Major ?? 0, depVersion.Minor ?? 0, depVersion.Patch ?? 0, depVersion.PreRelease, ""); var depName = pkg.Dependencies.First().Name; packages = PackageRepositoryHelpers.GetPackagesFromAllRepos(repositories, new PackageSpecifier("BasicSteps"), new PackageIdentifier(depName, version, CpuArchitecture.Unspecified, null)); CollectionAssert.IsNotEmpty(packages, "Repository does not list any compatible \"BasicSteps\" package."); Assert.IsTrue(packages.First().Name == "BasicSteps"); } finally { if (File.Exists("BasicSteps.TapPackage")) { File.Delete("BasicSteps.TapPackage"); } if (File.Exists(pkgName)) { File.Delete(pkgName); } } }
List <PackageDef> get(IPackageIdentifier compatibleWith) { var packages = PackageRepositoryHelpers.GetPackagesFromAllRepos(PackageManagerSettings.Current.Repositories.Where(p => p.IsEnabled).Select(s => s.Manager).ToList(), new PackageSpecifier(os: "Windows"), compatibleWith); return(packages); }