Exemplo n.º 1
0
            public async Task DoesNotRetrySeriousFailures()
            {
                var leaf = CreateCatalogLeaf();

                ExternalIconContentProviderMock
                .SetupSequence(cp => cp.TryGetResponseAsync(
                                   It.Is <Uri>(u => u.AbsoluteUri == IconUrlString),
                                   CancellationToken.None))
                .ReturnsAsync(TryGetResponseResult.FailCannotRetry())
                .ReturnsAsync(
                    TryGetResponseResult.Success(
                        new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = ExternalIconContentMock.Object
                }));

                await Target.ProcessPackageDetailsLeafAsync(
                    DestinationStorageMock.Object,
                    IconCacheStorageMock.Object,
                    leaf,
                    IconUrlString,
                    null,
                    CancellationToken.None);

                ExternalIconContentProviderMock
                .Verify(
                    cp => cp.TryGetResponseAsync(
                        It.Is <Uri>(u => u.AbsoluteUri == IconUrlString),
                        CancellationToken.None),
                    Times.AtMostOnce);

                VerifyNoCopyFromExternalSource();
            }
Exemplo n.º 2
0
            public async Task RetriesExternalLocationFailures()
            {
                var leaf = CreateCatalogLeaf();

                ExternalIconContentProviderMock
                .SetupSequence(cp => cp.TryGetResponseAsync(
                                   It.Is <Uri>(u => u.AbsoluteUri == IconUrlString),
                                   CancellationToken.None))
                .ReturnsAsync(TryGetResponseResult.FailCanRetry())
                .ReturnsAsync(
                    TryGetResponseResult.Success(
                        new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = ExternalIconContentMock.Object
                }));

                await Target.ProcessPackageDetailsLeafAsync(
                    DestinationStorageMock.Object,
                    IconCacheStorageMock.Object,
                    leaf,
                    IconUrlString,
                    null,
                    CancellationToken.None);

                ExternalIconContentProviderMock
                .Verify(
                    cp => cp.TryGetResponseAsync(
                        It.Is <Uri>(u => u.AbsoluteUri == IconUrlString),
                        CancellationToken.None),
                    Times.AtLeast(2));

                IconProcessorMock
                .Verify(
                    ip => ip.CopyIconFromExternalSourceAsync(
                        ExternalIconStream,
                        DestinationStorageMock.Object,
                        "theid/3.4.2/icon",
                        CancellationToken.None,
                        "theid",
                        leaf.PackageIdentity.Version.ToNormalizedString()),
                    Times.Once);
            }