Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        internal void SetupDownloadLatestAsync([NotNull] Mock <INugetService> nugetServiceMock, [NotNull] SnapApp snapApp, string upstreamPackageId,
                                               [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 downloadResourceResult = snapApp.BuildDownloadResourceResult(packageStream, nuGetPackageSources);

            nugetServiceMock
            .Setup(x => x
                   .DownloadLatestAsync(
                       It.Is <string>(v => v.Equals(upstreamPackageId)),
                       It.IsAny <PackageSource>(),
                       It.IsAny <bool>(),
                       It.IsAny <bool>(),
                       It.IsAny <CancellationToken>())
                   )
            .ReturnsAsync(() => downloadResourceResult);
        }