Пример #1
0
        public async Task PackageExpander_ExpandsPackage_WithNupkgCopy()
        {
            // Arrange
            using (var package = TestPackagesCore.GetPackageWithNupkgCopy())
            {
                var version  = new NuGetVersion(package.Version);
                var identity = new PackageIdentity(package.Id, version);

                using (var packagesDir = TestDirectory.Create())
                {
                    var pathResolver = new VersionFolderPathResolver(packagesDir);

                    var token  = CancellationToken.None;
                    var logger = NullLogger.Instance;
                    var packageExtractionContext = new PackageExtractionContext(
                        packageSaveMode: PackageSaveMode.Defaultv3,
                        xmlDocFileSaveMode: XmlDocFileSaveMode.None,
                        clientPolicyContext: null,
                        logger: logger);

                    var versionFolderPathResolver = new VersionFolderPathResolver(packagesDir);

                    // Act
                    using (var packageDownloader = new LocalPackageArchiveDownloader(
                               null,
                               package.File.FullName,
                               identity,
                               logger))
                    {
                        await PackageExtractor.InstallFromSourceAsync(
                            identity,
                            packageDownloader,
                            versionFolderPathResolver,
                            packageExtractionContext,
                            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");
                }
            }
        }