예제 #1
0
        public async Task PackageExpander_ExpandsPackage_WithNupkgCopy()
        {
            // Arrange
            using (var package = TestPackages.GetPackageWithNupkgCopy())
            {
                var version  = new NuGetVersion(package.Version);
                var identity = new PackageIdentity(package.Id, version);

                var packagesDir  = TestFileSystemUtility.CreateRandomTestFolder();
                var pathResolver = new VersionFolderPathResolver(packagesDir);

                var token  = CancellationToken.None;
                var logger = NullLogger.Instance;
                var versionFolderPathContext = new VersionFolderPathContext(
                    identity,
                    packagesDir,
                    logger,
                    packageSaveMode: PackageSaveMode.Defaultv3,
                    xmlDocFileSaveMode: XmlDocFileSaveMode.None);

                // Act
                using (var stream = package.File.OpenRead())
                {
                    await PackageExtractor.InstallFromSourceAsync(async (d) => await stream.CopyToAsync(d),
                                                                  versionFolderPathContext,
                                                                  token);
                }

                // Assert
                var packageDir = pathResolver.GetInstallPath(package.Id, identity.Version);
                AssertDirectoryExists(packageDir, packageDir + " does not exist");

                var nupkgPath = pathResolver.GetPackageFilePath(package.Id, identity.Version);
                Assert.True(File.Exists(nupkgPath), nupkgPath + " does not exist");

                var dllPath = Path.Combine(packageDir, "lib", "net40", "one.dll");
                Assert.True(File.Exists(dllPath), dllPath + " does not exist");
            }
        }