Esempio n. 1
0
        public async Task GivenAFeedRequest_WithWithNoConsistencySpecifiedAndNoRequestOptions_ThenNoRequestOptionsAreCreated()
        {
            _innerClient.ReadDatabaseFeedAsync()
            .ReturnsForAnyArgs(CosmosDbMockingHelper.CreateFeedResponse(Enumerable.Empty <Database>(), new NameValueCollection()));
            await _fhirClient.ReadDatabaseFeedAsync();

            await _innerClient.Received().ReadDatabaseFeedAsync();

            await _cosmosResponseProcessor.Received(1).ProcessResponse(Arg.Any <FeedResponse <Database> >());
        }
Esempio n. 2
0
        public async Task GivenAFeedRequest_WhenMaxContinuationSizeIsSet_ThenFeedRequestIsUpdated()
        {
            IDocumentClient client = new FhirDocumentClient(_innerClient, _fhirRequestContextAccessor, 5, _cosmosResponseProcessor);

            _innerClient
            .ReadDatabaseFeedAsync(Arg.Is <FeedOptions>(o => o.ResponseContinuationTokenLimitInKb == 5))
            .Returns(CosmosDbMockingHelper.CreateFeedResponse(Enumerable.Empty <Database>(), new NameValueCollection()));

            await client.ReadDatabaseFeedAsync();

            await _cosmosResponseProcessor.Received(1).ProcessResponse(Arg.Any <FeedResponse <Database> >());
        }
Esempio n. 3
0
        public async Task GivenTwoFeedRequests_WhenExecuted_ThenTheResponseHeadersContainTheCumulativeRequestCharge()
        {
            _innerClient
            .ReadDatabaseFeedAsync(Arg.Any <FeedOptions>())
            .Returns(CosmosDbMockingHelper.CreateFeedResponse(Enumerable.Empty <Database>(), new NameValueCollection {
                { CosmosDbHeaders.RequestCharge, "10" }
            }));

            await _fhirClient.ReadDatabaseFeedAsync();

            await _fhirClient.ReadDatabaseFeedAsync();

            await _cosmosResponseProcessor.Received(2).ProcessResponse(Arg.Any <FeedResponse <Database> >());
        }
Esempio n. 4
0
        public async Task GivenAFeedRequest_WithSessionConsistency_ThenTheResponseHeadersContainTheSessionToken()
        {
            _innerClient
            .ReadDatabaseFeedAsync(Arg.Is <FeedOptions>(o => o.ConsistencyLevel == ConsistencyLevel.Session && o.SessionToken == "1"))
            .Returns(CosmosDbMockingHelper.CreateFeedResponse(Enumerable.Empty <Database>(), new NameValueCollection {
                { CosmosDbHeaders.SessionToken, "2" }
            }));

            _requestHeaders.Add(CosmosDbHeaders.ConsistencyLevel, "Session");
            _requestHeaders.Add(CosmosDbHeaders.SessionToken, "1");

            await _fhirClient.ReadDatabaseFeedAsync();

            await _cosmosResponseProcessor.Received(1).ProcessResponse(Arg.Any <FeedResponse <Database> >());
        }