コード例 #1
0
        public async Task SendRequest_WithoutCorrelationHeaders_ResponseWithCorrelationHeadersAndCorrelationAccess()
        {
            // Act
            _logger.LogInformation("GET -> '{Uri}'", DefaultRoute);
            using (HttpResponseMessage response = await HttpClient.GetAsync(DefaultRoute))
            {
                // Assert
                _logger.LogInformation("{StatusCode} <- {Uri}", response.StatusCode, DefaultRoute);
                Assert.Equal(HttpStatusCode.OK, response.StatusCode);

                string correlationId = GetResponseHeader(response, DefaultTransactionId);
                string requestId     = GetResponseHeader(response, DefaultOperationId);

                string json = await response.Content.ReadAsStringAsync();

                var content = JsonConvert.DeserializeAnonymousType(json, new { TransactionId = "", OperationId = "" });
                Assert.False(String.IsNullOrWhiteSpace(content.TransactionId), "Accessed 'X-Transaction-ID' cannot be blank");
                Assert.False(String.IsNullOrWhiteSpace(content.OperationId), "Accessed 'X-Operation-ID' cannot be blank");

                Assert.Equal(correlationId, content.TransactionId);
                Assert.Equal(requestId, content.OperationId);
            }
        }
コード例 #2
0
 private void TracePublishedEvent(string eventId, object events)
 {
     _testLogger.LogInformation($"Event '{eventId}' published - {JsonConvert.SerializeObject(events)}");
 }