public MirrorServiceIntegrationTest(ITestOutputHelper helper)
        {
            var logger = new XunitLoggerProvider(helper);

            tempDir = new TempDir();
            IPackageCacheService localPackages = new FileSystemPackageCacheService(tempDir.UniqueTempFolder);
            IPackageDownloader   downloader    = new PackageDownloader(new System.Net.Http.HttpClient(),
                                                                       logger.CreateLogger <PackageDownloader>("MirrorServiceItest"));
            MirrorOptions options = new MirrorOptions()
            {
                Enabled       = true,
                UpstreamIndex = new System.Uri("https://api.nuget.org/v3/index.json"),
                PackagesPath  = tempDir.UniqueTempFolder,
                PackageDownloadTimeoutSeconds = 10
            };

            mirrorService = new MirrorService(new NuGetClient(logger.CreateLogger <NuGetClient>("MirrorServiceItest")), localPackages, downloader, logger.CreateLogger <MirrorService>("MirrorServiceItest"), options);
        }
Exemple #2
0
        public MirrorServiceTest(ITestOutputHelper helper)
        {
            var logger = new XunitLoggerProvider(helper);

            localPackages = new Mock <IPackageCacheService>(MockBehavior.Strict);
            localPackages.Setup(p => p.AddPackageAsync(It.IsAny <Stream>())).Returns(Task.CompletedTask);
            downloader = new Mock <IPackageDownloader>(MockBehavior.Strict);
            downloader.Setup(d => d.DownloadOrNullAsync(It.IsAny <Uri>(), It.IsAny <CancellationToken>())).ReturnsAsync(new MemoryStream());
            MirrorOptions options = new MirrorOptions()
            {
                Enabled = true,
                PackageDownloadTimeoutSeconds = 10,
                UpstreamIndex = new Uri("http://example.com")
            };

            client     = new Mock <INuGetClient>(MockBehavior.Strict);
            sourceRepo = new Mock <ISourceRepository>(MockBehavior.Strict);
            sourceRepo.Setup(s => s.GetPackageUriAsync(It.Is <string>(p => p == "log4net"), It.Is <string>(p => p == "2.0.8"), It.IsAny <CancellationToken>()))
            .ReturnsAsync(new Uri("http://example.com/package/1"));
            client.Setup(c => c.GetRepository(options.UpstreamIndex)).Returns(sourceRepo.Object);
            mirrorService = new MirrorService(client.Object, localPackages.Object, downloader.Object, logger.CreateLogger <MirrorService>("MirrorServiceTest"), options);
        }