Example #1
0
            public async Task LoadsCursorsAndExecutesCollector()
            {
                await Target.ExecuteAsync();

                HttpMessageHandler.Verify(
                    x => x.OnSendAsync(It.IsAny <HttpRequestMessage>(), It.IsAny <CancellationToken>()),
                    Times.Never);
                CloudBlobClient.Verify(x => x.GetContainerReference(It.IsAny <string>()), Times.Never);
                Storage.Protected().Verify(
                    "OnLoadAsync",
                    Times.Once(),
                    ItExpr.IsAny <Uri>(),
                    ItExpr.IsAny <CancellationToken>());
                Storage.Protected().Verify(
                    "OnLoadAsync",
                    Times.Once(),
                    new Uri("https://example/azs/cursor.json"),
                    ItExpr.IsAny <CancellationToken>());
                Collector.Verify(
                    x => x.RunAsync(It.IsAny <DurableCursor>(), It.Is <MemoryCursor>(c => c.Value == DateTime.MaxValue.ToUniversalTime()), It.IsAny <CancellationToken>()),
                    Times.Once);
            }
Example #2
0
            public async Task LoadsDependencyCursorsIfConfigured()
            {
                Config.DependencyCursorUrls = new List <string>()
                {
                    "https://example/fc-1/cursor.json",
                    "https://example/fc-2/cursor.json",
                };
                HttpMessageHandler
                .Setup(x => x.OnSendAsync(It.IsAny <HttpRequestMessage>(), It.IsAny <CancellationToken>()))
                .ReturnsAsync(() => new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StringContent($"{{\"value\": \"{DateTimeOffset.UtcNow.ToString("O")}\"}}"),
                });

                await Target.ExecuteAsync();

                HttpMessageHandler.Verify(
                    x => x.OnSendAsync(It.IsAny <HttpRequestMessage>(), It.IsAny <CancellationToken>()),
                    Times.Exactly(2));
                HttpMessageHandler.Verify(
                    x => x.OnSendAsync(
                        It.Is <HttpRequestMessage>(r => r.RequestUri.AbsoluteUri == "https://example/fc-1/cursor.json"),
                        It.IsAny <CancellationToken>()),
                    Times.Once);
                HttpMessageHandler.Verify(
                    x => x.OnSendAsync(
                        It.Is <HttpRequestMessage>(r => r.RequestUri.AbsoluteUri == "https://example/fc-2/cursor.json"),
                        It.IsAny <CancellationToken>()),
                    Times.Once);
                Storage.Protected().Verify(
                    "OnLoadAsync",
                    Times.Once(),
                    new Uri("https://example/azs/cursor.json"),
                    ItExpr.IsAny <CancellationToken>());
                Collector.Verify(
                    x => x.RunAsync(It.IsAny <DurableCursor>(), It.IsAny <AggregateCursor>(), It.IsAny <CancellationToken>()),
                    Times.Once);
            }