public async Task GetInstalledSatelliteFilesAsync_ReturnsNullRuntimePackageDirectoryIfRuntimePackageDoesNotExist() { using (var test = PackageHelperTest.Create(TestPackagesCore.GetPackageContentReaderTestPackage())) { using (var testDirectory = TestDirectory.Create()) { var packageIdentity = new PackageIdentity("A", new NuGetVersion("1.2.3")); var packagePathResolver = new PackagePathResolver(testDirectory.Path); var satellitePackageInfo = await TestPackagesCore.GetSatellitePackageAsync( testDirectory.Path, packageIdentity.Id, packageIdentity.Version.ToNormalizedString(), language : "fr"); using (var packageReader = new PackageArchiveReader(File.OpenRead(satellitePackageInfo.FullName))) { var result = await PackageHelper.GetInstalledSatelliteFilesAsync( packageReader, packagePathResolver, PackageSaveMode.Defaultv3, CancellationToken.None); var runtimePackageDirectory = result.Item1; var satelliteFiles = result.Item2; Assert.Null(runtimePackageDirectory); Assert.Empty(satelliteFiles); } } } }
public async Task GetInstalledSatelliteFilesAsync_ReturnsEmptyEnumerableForNoInstalledSatelliteFiles() { using (var test = PackageHelperTest.Create(TestPackagesCore.GetPackageContentReaderTestPackage())) { using (var testDirectory = TestDirectory.Create()) { var packageIdentity = new PackageIdentity("A", new NuGetVersion("1.2.3")); var packagePathResolver = new PackagePathResolver(testDirectory.Path); var packageFileInfo = await TestPackagesCore.GetRuntimePackageAsync( testDirectory.Path, packageIdentity.Id, packageIdentity.Version.ToNormalizedString()); var satellitePackageInfo = await TestPackagesCore.GetSatellitePackageAsync( testDirectory.Path, packageIdentity.Id, packageIdentity.Version.ToNormalizedString(), language : "fr"); // Install runtime package using (var packageReader = new PackageArchiveReader(File.OpenRead(packageFileInfo.FullName))) using (var packageStream = File.OpenRead(packageFileInfo.FullName)) { await PackageExtractor.ExtractPackageAsync( test.Root, packageReader, packageStream, packagePathResolver, new PackageExtractionContext( PackageSaveMode.Defaultv2, PackageExtractionBehavior.XmlDocFileSaveMode, NullLogger.Instance, signedPackageVerifier : null, signedPackageVerifierSettings : null), CancellationToken.None); } using (var packageReader = new PackageArchiveReader(File.OpenRead(satellitePackageInfo.FullName))) { var result = await PackageHelper.GetInstalledSatelliteFilesAsync( packageReader, packagePathResolver, PackageSaveMode.Defaultv3, CancellationToken.None); var runtimePackageDirectory = result.Item1; var satelliteFiles = result.Item2; var packageDirectoryName = $"{packageIdentity.Id}.{packageIdentity.Version.ToNormalizedString()}"; Assert.Equal(Path.Combine(testDirectory.Path, packageDirectoryName), runtimePackageDirectory); Assert.Empty(satelliteFiles); } } } }
public async Task GetInstalledPackageFilesAsync_ReturnsEmptyEnumerableIfNoPackageFilesInstalled() { using (var test = PackageHelperTest.Create(TestPackagesCore.GetPackageContentReaderTestPackage())) { var files = await PackageHelper.GetInstalledPackageFilesAsync( test.Reader, test.Reader.GetIdentity(), test.Resolver, PackageSaveMode.Defaultv3, CancellationToken.None); Assert.Empty(files); } }
public async Task GetInstalledPackageFilesAsync_ReturnsInstalledPackageFiles() { using (var test = PackageHelperTest.Create(TestPackagesCore.GetPackageContentReaderTestPackage())) { using (var packageStream = test.GetPackageStream()) { await PackageExtractor.ExtractPackageAsync( test.Root, test.Reader, packageStream, test.Resolver, new PackageExtractionContext( PackageSaveMode.Defaultv2, PackageExtractionBehavior.XmlDocFileSaveMode, clientPolicyContext : null, logger : NullLogger.Instance), CancellationToken.None); } var packageIdentity = test.Reader.GetIdentity(); var packageDirectoryName = $"{packageIdentity.Id}.{packageIdentity.Version.ToNormalizedString()}"; // Delete some files so that the set of installed files is incomplete. Directory.Delete(Path.Combine(test.Root, packageDirectoryName, "lib"), recursive: true); var files = (await PackageHelper.GetInstalledPackageFilesAsync( test.Reader, test.Reader.GetIdentity(), test.Resolver, PackageSaveMode.Defaultv3, CancellationToken.None)).ToArray(); Assert.Equal(9, files.Length); Assert.Equal(Path.Combine(test.Root, packageDirectoryName, "build/net45/a.dll"), files[0].FileFullPath); Assert.Equal(Path.Combine(test.Root, packageDirectoryName, "build/net45/a.props"), files[1].FileFullPath); Assert.Equal(Path.Combine(test.Root, packageDirectoryName, "build/net45/a.targets"), files[2].FileFullPath); Assert.Equal(Path.Combine(test.Root, packageDirectoryName, "content/net45/b"), files[3].FileFullPath); Assert.Equal(Path.Combine(test.Root, packageDirectoryName, "content/net45/c"), files[4].FileFullPath); Assert.Equal(Path.Combine(test.Root, packageDirectoryName, "other/net45/h"), files[5].FileFullPath); Assert.Equal(Path.Combine(test.Root, packageDirectoryName, "other/net45/i"), files[6].FileFullPath); Assert.Equal(Path.Combine(test.Root, packageDirectoryName, "tools/net45/j"), files[7].FileFullPath); Assert.Equal(Path.Combine(test.Root, packageDirectoryName, "tools/net45/k"), files[8].FileFullPath); } }