public async Task RequestDepth_FromCustomRequestHeader_RequestId()
        {
            var customRequestHeader = "custom-rc-header";

            var originalDepth = 4;
            var expectedDepth = 5;

            var existingRequestId = new RequestIdBuilder()
                                    .WithDepth(originalDepth)
                                    .WithHeader(customRequestHeader)
                                    .Build();

            var options = new RequestChainOptions
            {
                RequestIdHeaderKey = customRequestHeader
            };

            using (var server = new RequestIdTestServer(options))
                using (var client = server.CreateClient())
                {
                    client.ApplyRequestChain(existingRequestId);

                    var result = await client.MakeRequestAndGetRequestDepth();

                    result.Should()
                    .Be(expectedDepth, "the original depth should increment when ApplyRequestChain is called on client");
                }
        }
        public async Task RequestDepthExcluded_ExistingRequestWithoutDepth_HeaderWithRequestId()
        {
            var existingRequestId = new RequestIdBuilder()
                                    .WithNoDepth()
                                    .Build();

            var options = new RequestChainOptions
            {
                IncludeRequestDepth = false
            };

            Guid requestIdGuid;

            using (var server = new RequestIdTestServer(options))
                using (var client = server.CreateClient())
                {
                    client.ApplyRequestChain(existingRequestId);

                    var result = await client.MakeRequestAndGetRequestHeader();

                    result.Should()
                    .NotBeNullOrWhiteSpace();
                    result.Should()
                    .NotContain(":", "the header only contains the request, not the depth");
                    Guid.TryParse(result, out requestIdGuid)
                    .Should()
                    .BeTrue();
                }
        }
        public async Task RequestId_FromCustomRequestHeader_RequestId()
        {
            var customRequestHeader = "custom-rc-header";
            var expectedId          = Guid.NewGuid();

            var existingRequestId = new RequestIdBuilder()
                                    .WithRequetId(expectedId)
                                    .WithHeader(customRequestHeader)
                                    .Build();

            var options = new RequestChainOptions
            {
                RequestIdHeaderKey = customRequestHeader
            };

            using (var server = new RequestIdTestServer(options))
                using (var client = server.CreateClient())
                {
                    client.ApplyRequestChain(existingRequestId);

                    var result = await client.MakeRequestAndGetRequestId();

                    result.Should()
                    .Be(expectedId, "the requestId comes from the existing request");
                }
        }
예제 #4
0
        public async Task RequestId_ExistingRequest_MaintainsId()
        {
            var expectedId        = Guid.NewGuid();
            var existingRequestId = new RequestIdBuilder()
                                    .WithRequetId(expectedId)
                                    .Build();

            using (var client = _fixture.CreateClient())
            {
                client.ApplyRequestChain(existingRequestId);

                var result = await client.MakeRequestAndGetRequestId();

                result.Should()
                .Be(expectedId, "the requestId comes from the existing request");
            }
        }
예제 #5
0
        public async Task RequestDepth_ExistingRequest_AddsOne()
        {
            var originalDepth     = 4;
            var expectedDepth     = 5;
            var existingRequestId = new RequestIdBuilder()
                                    .WithDepth(originalDepth)
                                    .Build();

            using (var client = _fixture.CreateClient())
            {
                client.ApplyRequestChain(existingRequestId);

                var result = await client.MakeRequestAndGetRequestDepth();

                result.Should()
                .Be(expectedDepth, "the original depth should increment when ApplyRequestChain is called on client");
            }
        }
        public async Task RequestDepthExcluded_ExistingRequestWithoutDepth_DepthNull()
        {
            var existingRequestId = new RequestIdBuilder()
                                    .WithNoDepth()
                                    .Build();

            var options = new RequestChainOptions
            {
                IncludeRequestDepth = false
            };

            using (var server = new RequestIdTestServer(options))
                using (var client = server.CreateClient())
                {
                    client.ApplyRequestChain(existingRequestId);

                    var result = await client.MakeRequestAndGetRequestDepth();

                    result.Should()
                    .Be(null, "the request depth is disabled in options");
                }
        }