public Task <HttpResponseData> RunAsync(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "peek/aggregations")]
            HttpRequestData request)
        {
            return(request.ProcessAsync(async() =>
            {
                var command = new PeekAggregationsCommand(_operatorIdentity.ActorId, _bundleIdProvider.TryGetBundleId(request));
                var(hasContent, bundleId, stream, documentTypes) = await _mediator
                                                                   .Send(command)
                                                                   .ConfigureAwait(false);

                var response = hasContent
                    ? request.CreateResponse(stream, MediaTypeNames.Application.Xml)
                    : request.CreateResponse(HttpStatusCode.NoContent);

                response.Headers.Add(Constants.BundleIdHeaderName, bundleId);

                if (_featureFlags.IsFeatureActive(Feature.SendMessageTypeHeader))
                {
                    response.Headers.Add(Constants.MessageTypeName, string.Join(",", documentTypes));
                }

                return response;
            }));
        }
        public void Given_Request_When_BundleIdIsNotInQuery_Then_NullIsReturned()
        {
            Uri uri     = new($"https://localhost/");
            var request = MockHelpers.CreateHttpRequestData(url: uri);

            var sut      = new ExternalBundleIdProvider();
            var actualId = sut.TryGetBundleId(request);

            actualId.Should().BeNull();
        }
        public void Given_Request_When_BundleIdIsPresent_Then_ItIsReturned()
        {
            // Arrange
            var expectedBundleId = Guid.NewGuid().ToString("N");
            Uri uri     = new($"https://localhost/?{Constants.BundleIdQueryName}={expectedBundleId}");
            var request = MockHelpers.CreateHttpRequestData(url: uri);

            // Act
            var sut      = new ExternalBundleIdProvider();
            var actualId = sut.TryGetBundleId(request);

            // Assert
            actualId.Should().Be(expectedBundleId);
        }