Esempio n. 1
0
            public async Task CanFetchTheEntireCatalog()
            {
                var output = await Target.Object.RunAsync(Front, Back, Token);

                Assert.Equal(OrderedCommitIds.ToArray(), Target.Object.Batches.Select(x => x.Single().CommitId).ToArray());
                HttpRetryStrategy.Verify(
                    x => x.SendAsync(It.IsAny <HttpClient>(), It.IsAny <Uri>(), It.IsAny <CancellationToken>()),
                    Times.Exactly(5));
                HttpRetryStrategy.Verify(x => x.SendAsync(It.IsAny <HttpClient>(), new Uri("https://example/catalog/index.json"), It.IsAny <CancellationToken>()));
                HttpRetryStrategy.Verify(x => x.SendAsync(It.IsAny <HttpClient>(), new Uri("https://example/catalog/page0.json"), It.IsAny <CancellationToken>()));
                HttpRetryStrategy.Verify(x => x.SendAsync(It.IsAny <HttpClient>(), new Uri("https://example/catalog/page1.json"), It.IsAny <CancellationToken>()));
                HttpRetryStrategy.Verify(x => x.SendAsync(It.IsAny <HttpClient>(), new Uri("https://example/catalog/page2.json"), It.IsAny <CancellationToken>()));
                HttpRetryStrategy.Verify(x => x.SendAsync(It.IsAny <HttpClient>(), new Uri("https://example/catalog/page3.json"), It.IsAny <CancellationToken>()));
            }
Esempio n. 2
0
            public async Task FetchesUpToNextPageWhenBackCursorIsAtTheBeginningOfTheNonLastPage()
            {
                Front.Value = DateTime.Parse("2019-11-04T00:30:00");
                Back.Value  = DateTime.Parse("2019-11-04T01:01:00");

                var output = await Target.Object.RunAsync(Front, Back, Token);

                Assert.Equal(OrderedCommitIds.Skip(2).Take(2).ToArray(), Target.Object.Batches.Select(x => x.Single().CommitId).ToArray());
                HttpRetryStrategy.Verify(
                    x => x.SendAsync(It.IsAny <HttpClient>(), It.IsAny <Uri>(), It.IsAny <CancellationToken>()),
                    Times.Exactly(3));
                HttpRetryStrategy.Verify(x => x.SendAsync(It.IsAny <HttpClient>(), new Uri("https://example/catalog/index.json"), It.IsAny <CancellationToken>()));
                HttpRetryStrategy.Verify(x => x.SendAsync(It.IsAny <HttpClient>(), new Uri("https://example/catalog/page0.json"), It.IsAny <CancellationToken>()));
                HttpRetryStrategy.Verify(x => x.SendAsync(It.IsAny <HttpClient>(), new Uri("https://example/catalog/page1.json"), It.IsAny <CancellationToken>()));
            }
Esempio n. 3
0
            public async Task SkipsPagesWhenFrontCursorIsAfterEnd()
            {
                Front.Value = DateTime.Parse("2019-11-04T01:00:00");
                Back.Value  = DateTime.Parse("2019-11-04T02:01:00");

                var output = await Target.Object.RunAsync(Front, Back, Token);

                Assert.Equal(OrderedCommitIds.Skip(3).Take(4).ToArray(), Target.Object.Batches.Select(x => x.Single().CommitId).ToArray());
                HttpRetryStrategy.Verify(
                    x => x.SendAsync(It.IsAny <HttpClient>(), It.IsAny <Uri>(), It.IsAny <CancellationToken>()),
                    Times.Exactly(3));
                HttpRetryStrategy.Verify(x => x.SendAsync(It.IsAny <HttpClient>(), new Uri("https://example/catalog/index.json"), It.IsAny <CancellationToken>()));
                HttpRetryStrategy.Verify(x => x.SendAsync(It.IsAny <HttpClient>(), new Uri("https://example/catalog/page1.json"), It.IsAny <CancellationToken>()));
                HttpRetryStrategy.Verify(x => x.SendAsync(It.IsAny <HttpClient>(), new Uri("https://example/catalog/page2.json"), It.IsAny <CancellationToken>()));
            }