Exemplo n.º 1
0
        public async Task LocalDownloadResource_PackageIsReturnedUnzippedFolderAsync()
        {
            using (var root = TestDirectory.Create())
            {
                // Arrange
                var testLogger = new TestLogger();

                var id = new PackageIdentity("a", NuGetVersion.Parse("1.0.0"));
                await SimpleTestPackageUtility.CreateFolderFeedUnzipAsync(root, id);

                string packagesFolder = null; // This is unused by the implementation.

                var localResource = new FindLocalPackagesResourceUnzipped(root);
                var resource      = new LocalDownloadResource(localResource);

                // Act
                using (var cacheContext = new SourceCacheContext())
                    using (var result = await resource.GetDownloadResourceResultAsync(
                               id,
                               new PackageDownloadContext(cacheContext),
                               packagesFolder,
                               testLogger,
                               CancellationToken.None))
                    {
                        // Assert
                        Assert.Equal(DownloadResourceResultStatus.Available, result.Status);
                        Assert.Equal("a", result.PackageReader.GetIdentity().Id);
                        Assert.Equal("1.0.0", result.PackageReader.GetIdentity().Version.ToFullString());
                        Assert.True(result.PackageStream.CanSeek);
                        Assert.True(result.PackageReader is PackageFolderReader);
                    }
            }
        }
Exemplo n.º 2
0
        private async Task CreateFeedsAsync(string rootV2, string rootV3, string rootUnzip, string rootPackagesConfig, params PackageIdentity[] packages)
        {
            foreach (var package in packages)
            {
                await SimpleTestPackageUtility.CreateFolderFeedV2Async(rootV2, package);

                await SimpleTestPackageUtility.CreateFolderFeedV3Async(rootV3, package);

                await SimpleTestPackageUtility.CreateFolderFeedUnzipAsync(rootUnzip, package);

                await SimpleTestPackageUtility.CreateFolderFeedPackagesConfigAsync(rootPackagesConfig, package);
            }
        }