public async Task TestDownloadPackage_InV2()
        {
            // Arrange
            var sourceRepositoryProvider = TestSourceRepositoryUtility.CreateV2OnlySourceRepositoryProvider();
            var v2sourceRepository       = sourceRepositoryProvider.GetRepositories().First();
            var packageIdentity          = new PackageIdentity("jQuery", new NuGetVersion("1.8.2"));

            // Act
            using (var cacheContext = new SourceCacheContext())
                using (var packagesDirectory = TestDirectory.Create())
                    using (var downloadResult = await PackageDownloader.GetDownloadResourceResultAsync(v2sourceRepository,
                                                                                                       packageIdentity,
                                                                                                       new PackageDownloadContext(cacheContext),
                                                                                                       packagesDirectory,
                                                                                                       NullLogger.Instance,
                                                                                                       CancellationToken.None))
                    {
                        var targetPackageStream = downloadResult.PackageStream;

                        // Assert
                        // jQuery.1.8.2 is of size 185476 bytes. Make sure the download is successful
                        Assert.Equal(185476, targetPackageStream.Length);
                        Assert.True(targetPackageStream.CanSeek);
                    }
        }
        public async Task TestDownloadThrows_PackageDoesNotExist_InV2()
        {
            // Arrange
            var sourceRepositoryProvider = TestSourceRepositoryUtility.CreateV2OnlySourceRepositoryProvider();
            var v2sourceRepository       = sourceRepositoryProvider.GetRepositories().First();
            var packageId       = Guid.NewGuid().ToString();
            var packageIdentity = new PackageIdentity(packageId, new NuGetVersion("1.0.0"));

            // Act
            Exception exception = null;

            try
            {
                using (var cacheContext = new SourceCacheContext())
                    using (var packagesDirectory = TestDirectory.Create())
                    {
                        await PackageDownloader.GetDownloadResourceResultAsync(v2sourceRepository,
                                                                               packageIdentity,
                                                                               new PackageDownloadContext(cacheContext),
                                                                               packagesDirectory,
                                                                               NullLogger.Instance,
                                                                               CancellationToken.None);
                    }
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            // Assert
            Assert.NotNull(exception);
        }
Beispiel #3
0
        public async Task GetDownloadResourceResultAsync_V2_DownloadsPackage()
        {
            // Arrange
            var sourceRepositoryProvider = TestSourceRepositoryUtility.CreateV2OnlySourceRepositoryProvider();
            var v2sourceRepository       = sourceRepositoryProvider.GetRepositories().First();
            var packageIdentity          = new PackageIdentity("jQuery", new NuGetVersion("1.8.2"));

            // Act
            using (var cacheContext = new SourceCacheContext())
                using (var packagesDirectory = TestDirectory.Create())
                    using (var downloadResult = await PackageDownloader.GetDownloadResourceResultAsync(
                               v2sourceRepository,
                               packageIdentity,
                               new PackageDownloadContext(cacheContext),
                               packagesDirectory,
                               NullLogger.Instance,
                               CancellationToken.None))
                    {
                        var targetPackageStream = downloadResult.PackageStream;

                        using (var packageArchiveReader = new PackageArchiveReader(targetPackageStream))
                        {
                            var contentHash = packageArchiveReader.GetContentHash(CancellationToken.None);

                            // Assert
                            Assert.Equal(_jQuery182ContentHash, contentHash);
                            Assert.True(targetPackageStream.CanSeek);
                        }
                    }
        }
        public async Task GetDownloadResourceResultAsync_WithDirectDownloadAndV2Source_SkipsGlobalPackagesFolder()
        {
            // Arrange
            var sourceRepositoryProvider = TestSourceRepositoryUtility.CreateV2OnlySourceRepositoryProvider();

            // Act & Assert
            await VerifyDirectDownloadSkipsGlobalPackagesFolder(sourceRepositoryProvider);
        }
Beispiel #5
0
        public async Task TestPacManCleanInstall()
        {
            var target = new PackageIdentity("Umbraco", NuGetVersion.Parse("5.1.0.175"));

            _output.WriteLine("target: {0}", target);

            var actionsV2 = await PacManCleanInstall(TestSourceRepositoryUtility.CreateV2OnlySourceRepositoryProvider(), target);

            var actionsV3 = await PacManCleanInstall(TestSourceRepositoryUtility.CreateV3OnlySourceRepositoryProvider(), target);

            Assert.True(Compare(actionsV2, actionsV3));
        }
        public async Task GetDownloadResourceResultAsync_V2_DownloadsPackage()
        {
            // Arrange
            var sourceRepositoryProvider = TestSourceRepositoryUtility.CreateV2OnlySourceRepositoryProvider();
            var v2sourceRepository       = sourceRepositoryProvider.GetRepositories().First();
            var packageIdentity          = new PackageIdentity("jQuery", new NuGetVersion("1.8.2"));

            // Act
            using (var cacheContext = new SourceCacheContext())
            {
                var downloadContext = new PackageDownloadContext(cacheContext)
                {
                    ExtractionContext = new PackageExtractionContext(
                        PackageSaveMode.Defaultv3,
                        PackageExtractionBehavior.XmlDocFileSaveMode,
                        NullLogger.Instance,
                        signedPackageVerifier: null,
                        signedPackageVerifierSettings: null)
                };

                using (var packagesDirectory = TestDirectory.Create())
                    using (var downloadResult = await PackageDownloader.GetDownloadResourceResultAsync(
                               v2sourceRepository,
                               packageIdentity,
                               downloadContext,
                               packagesDirectory,
                               NullLogger.Instance,
                               CancellationToken.None))
                    {
                        var targetPackageStream = downloadResult.PackageStream;

                        // Assert
                        // jQuery.1.8.2 is of size 185476 bytes. Make sure the download is successful
                        Assert.Equal(185476, targetPackageStream.Length);
                        Assert.True(targetPackageStream.CanSeek);
                    }
            }
        }