public void PackageReader_AgnosticFramework() { var zip = TestPackages.GetZip(TestPackages.GetLegacyContentPackage()); using (PackageReader reader = new PackageReader(zip)) { string[] frameworks = reader.GetSupportedFrameworks().Select(f => f.DotNetFrameworkName).ToArray(); Assert.Equal("Agnostic, Version=v0.0", frameworks[0]); Assert.Equal(frameworks.Length, 1); } }
public void PackageReader_ContentNoFrameworks() { var zip = TestPackages.GetZip(TestPackages.GetLegacyContentPackage()); using (PackageReader reader = new PackageReader(zip)) { var groups = reader.GetContentItems().ToArray(); Assert.Equal(1, groups.Count()); Assert.Equal(NuGetFramework.AnyFramework, groups.Single().TargetFramework); Assert.Equal(3, groups.Single().Items.Count()); } }
public async Task TestFolderNuGetProjectDeletePackage() { // Arrange var packageIdentity = new PackageIdentity("packageA", new NuGetVersion("1.0.0")); var randomTestSourcePath = TestFilesystemUtility.CreateRandomTestFolder(); var packageFileInfo = TestPackages.GetLegacyContentPackage(randomTestSourcePath, packageIdentity.Id, packageIdentity.Version.ToNormalizedString()); var randomTestDestinationPath = TestFilesystemUtility.CreateRandomTestFolder(); var folderNuGetProject = new FolderNuGetProject(randomTestDestinationPath); var packagePathResolver = new PackagePathResolver(randomTestDestinationPath); var packageInstallPath = packagePathResolver.GetInstallPath(packageIdentity); var nupkgFilePath = Path.Combine(packageInstallPath, packagePathResolver.GetPackageFileName(packageIdentity)); var testNuGetProjectContext = new TestNuGetProjectContext(); var token = CancellationToken.None; using (var packageStream = packageFileInfo.OpenRead()) { // Act await folderNuGetProject.InstallPackageAsync(packageIdentity, packageStream, testNuGetProjectContext, token); } var unNormalizedPackageIdentity = new PackageIdentity(packageIdentity.Id, new NuGetVersion(packageIdentity.Version + ".0")); // Assert Assert.True(File.Exists(nupkgFilePath)); Assert.True(File.Exists(Path.Combine(packageInstallPath, "Content/Scripts/test1.js"))); using (var packageStream = File.OpenRead(nupkgFilePath)) { var zipArchive = new ZipArchive(packageStream); Assert.Equal(6, zipArchive.Entries.Count); } Assert.True(folderNuGetProject.PackageExists(packageIdentity)); var packageDirectoryPath = folderNuGetProject.GetInstalledPath(unNormalizedPackageIdentity); Assert.True(!String.IsNullOrEmpty(packageDirectoryPath)); Assert.True(Directory.Exists(packageDirectoryPath)); // Main Act await folderNuGetProject.DeletePackage(packageIdentity, testNuGetProjectContext, CancellationToken.None); // Assert Assert.False(folderNuGetProject.PackageExists(unNormalizedPackageIdentity)); // Check that the package directories are deleted Assert.False(Directory.Exists(packageDirectoryPath)); // Clean-up TestFilesystemUtility.DeleteRandomTestFolders(randomTestSourcePath, randomTestDestinationPath); }