示例#1
0
            internal Test(bool useStorage = true)
            {
                Handler     = new MockServerHttpClientHandler();
                _httpClient = new HttpClient(Handler);

                PackageFileName    = $"{PackageId.ToLowerInvariant()}.{PackageVersion.ToLowerInvariant()}.nupkg";
                Timestamp          = DateTime.UtcNow;
                ContentUri         = new Uri($"https://nuget.test/packages/{PackageFileName}");
                PackageUri         = Utilities.GetNugetCacheBustingUri(ContentUri, Timestamp.ToString("O"));
                Storage            = new Mock <IAzureStorage>(MockBehavior.Strict);
                Blob               = new Mock <ICloudBlockBlob>(MockBehavior.Strict);
                FeedPackageDetails = new FeedPackageDetails(
                    ContentUri,
                    Timestamp.AddHours(-3),
                    Timestamp.AddHours(-2),
                    Timestamp.AddHours(-1),
                    PackageId,
                    PackageVersion,
                    PackageVersion);

                var stream = TestHelper.GetStream(PackageFileName + ".testdata");

                Handler.SetAction(
                    PackageUri.PathAndQuery,
                    request => Task.FromResult(
                        new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StreamContent(stream)
                }));

                TelemetryService = new MockTelemetryService();

                Creator = PackageCatalogItemCreator.Create(
                    _httpClient,
                    TelemetryService,
                    Mock.Of <ILogger>(),
                    useStorage ? Storage.Object : null);
            }