public async Task SendRequest_WithVersionTracking_AddsApplicationVersionToResponse()
        {
            // Arrange
            string expected = $"version-{Guid.NewGuid()}";

            _testServer.AddServicesConfig(services => services.AddSingleton <IAppVersion>(provider => new StubAppVersion(expected)));
            _testServer.AddConfigure(app => app.UseVersionTracking());

            using (HttpClient client = _testServer.CreateClient())
                // Act
                using (HttpResponseMessage response = await client.GetAsync(EchoController.Route))
                {
                    // Assert
                    Assert.True(response.Headers.TryGetValues(DefaultHeaderName, out IEnumerable <string> values));
                    Assert.Equal(expected, Assert.Single(values));
                }
        }
Esempio n. 2
0
        public async Task SendRequest_WithCorrelateOptionsNotAllowTransactionInRequest_ResponseWithBadRequest()
        {
            // Arrange
            _testServer.AddServicesConfig(services => services.Configure <CorrelationInfoOptions>(options => options.Transaction.AllowInRequest = false));

            using (HttpClient client = _testServer.CreateClient())
                using (var request = new HttpRequestMessage(HttpMethod.Get, Route))
                {
                    request.Headers.Add(DefaultTransactionId, Guid.NewGuid().ToString());

                    // Act
                    using (HttpResponseMessage response = await client.SendAsync(request))
                    {
                        // Assert
                        Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
                        Assert.DoesNotContain(response.Headers, header => header.Key == DefaultOperationId);
                        Assert.DoesNotContain(response.Headers, header => header.Key == DefaultTransactionId);
                    }
                }
        }