예제 #1
0
        internal void SetupDownloadAsyncWithProgressAsync([NotNull] Mock <INugetService> nugetServiceMock, [NotNull] SnapApp snapApp,
                                                          [NotNull] MemoryStream packageStream, [NotNull] INuGetPackageSources nuGetPackageSources)
        {
            if (nugetServiceMock == null)
            {
                throw new ArgumentNullException(nameof(nugetServiceMock));
            }
            if (snapApp == null)
            {
                throw new ArgumentNullException(nameof(snapApp));
            }
            if (packageStream == null)
            {
                throw new ArgumentNullException(nameof(packageStream));
            }
            if (nuGetPackageSources == null)
            {
                throw new ArgumentNullException(nameof(nuGetPackageSources));
            }

            var packageIdentity        = snapApp.BuildPackageIdentity();
            var downloadResourceResult = snapApp.BuildDownloadResourceResult(packageStream, nuGetPackageSources);

            nugetServiceMock
            .Setup(x => x.DownloadAsyncWithProgressAsync(
                       It.IsAny <PackageSource>(),
                       It.Is <DownloadContext>(v => v.PackageIdentity.Equals(packageIdentity)),
                       It.IsAny <INugetServiceProgressSource>(),
                       It.IsAny <CancellationToken>()
                       ))
            .ReturnsAsync(() => downloadResourceResult);
        }
예제 #2
0
        internal static NuGetPackageSearchMedatadata BuildPackageSearchMetadata([NotNull] this SnapApp snapApp,
                                                                                [NotNull] INuGetPackageSources nugetSources)
        {
            if (snapApp == null)
            {
                throw new ArgumentNullException(nameof(snapApp));
            }
            if (nugetSources == null)
            {
                throw new ArgumentNullException(nameof(nugetSources));
            }

            var channel       = snapApp.GetCurrentChannelOrThrow();
            var updateFeed    = (SnapNugetFeed)channel.UpdateFeed;
            var packageSource = nugetSources.Items.Single(x => x.Name == updateFeed.Name && x.SourceUri == updateFeed.Source);

            return(new NuGetPackageSearchMedatadata(snapApp.BuildPackageIdentity(), packageSource, DateTimeOffset.Now, new List <PackageDependency>()));
        }