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 GetSatelliteFilesAsync_ReturnsSatelliteFilesForSatellitePackage() { 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"); using (var packageReader = new PackageArchiveReader(File.OpenRead(satellitePackageInfo.FullName))) { var result = await PackageHelper.GetSatelliteFilesAsync(packageReader, packagePathResolver, CancellationToken.None); var runtimePackageDirectory = result.Item1; var satelliteFiles = result.Item2; Assert.Equal(testDirectory.Path, runtimePackageDirectory); Assert.Equal(new[] { "lib/net45/fr/A.resources.dll" }, satelliteFiles); } } }
public async Task GetInstalledSatelliteFilesAsync_ReturnsInstalledSatelliteFiles() { 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( packageReader, packageStream, packagePathResolver, new PackageExtractionContext(NullLogger.Instance), CancellationToken.None); } // Install satellite package using (var packageReader = new PackageArchiveReader(File.OpenRead(satellitePackageInfo.FullName))) using (var packageStream = File.OpenRead(satellitePackageInfo.FullName)) { await PackageExtractor.ExtractPackageAsync( packageReader, packageStream, packagePathResolver, new PackageExtractionContext(NullLogger.Instance), 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.ToArray(); var packageDirectoryName = $"{packageIdentity.Id}.{packageIdentity.Version.ToNormalizedString()}"; Assert.Equal(Path.Combine(testDirectory.Path, packageDirectoryName), runtimePackageDirectory); Assert.Equal(1, satelliteFiles.Length); Assert.Equal(Path.Combine(testDirectory.Path, packageDirectoryName, "lib/net45/fr/A.resources.dll"), satelliteFiles[0].FileFullPath); } } }
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); } } } }