public async Task LocalDownloadResource_PackageIsReturnedUnzippedFolder()
        {
            using (var root = TestFileSystemUtility.CreateRandomTestFolder())
            {
                // Arrange
                var testLogger = new TestLogger();

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

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

                // Act
                var result = await resource.GetDownloadResourceResultAsync(
                    id,
                    NullSettings.Instance,
                    testLogger,
                    CancellationToken.None);

                using (var reader = result.PackageReader)
                    using (var stream = result.PackageStream)
                    {
                        // Assert
                        Assert.Equal(DownloadResourceResultStatus.Available, result.Status);
                        Assert.Equal("a", reader.GetIdentity().Id);
                        Assert.Equal("1.0.0", reader.GetIdentity().Version.ToFullString());
                        Assert.True(stream.CanSeek);
                        Assert.True(reader is PackageFolderReader);
                    }
            }
        }
        private async Task CreateFeeds(string rootV2, string rootV3, string rootUnzip, string rootPackagesConfig, params PackageIdentity[] packages)
        {
            foreach (var package in packages)
            {
                SimpleTestPackageUtility.CreateFolderFeedV2(rootV2, package);
                await SimpleTestPackageUtility.CreateFolderFeedV3(rootV3, package);

                SimpleTestPackageUtility.CreateFolderFeedUnzip(rootUnzip, package);
                await SimpleTestPackageUtility.CreateFolderFeedPackagesConfigAsync(rootPackagesConfig, package);
            }
        }
Exemplo n.º 3
0
        public async Task LocalDownloadResource_PackageIsReturnedUnzippedFolder()
        {
            using (var root = TestDirectory.Create())
            {
                // Arrange
                var testLogger = new TestLogger();

                var id = new PackageIdentity("a", NuGetVersion.Parse("1.0.0"));
                SimpleTestPackageUtility.CreateFolderFeedUnzip(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())
                {
                    var result = await resource.GetDownloadResourceResultAsync(
                        id,
                        new PackageDownloadContext(cacheContext),
                        packagesFolder,
                        testLogger,
                        CancellationToken.None);

                    using (var reader = result.PackageReader)
                        using (var stream = result.PackageStream)
                        {
                            // Assert
                            Assert.Equal(DownloadResourceResultStatus.Available, result.Status);
                            Assert.Equal("a", reader.GetIdentity().Id);
                            Assert.Equal("1.0.0", reader.GetIdentity().Version.ToFullString());
                            Assert.True(stream.CanSeek);
                            Assert.True(reader is PackageFolderReader);
                        }
                }
            }
        }