public CorrelationIdHandlerTests() { _correlationIdAccessor = A.Fake <ICorrelationIdAccessor>(); _underTest = new CorrelationIdHandler(_correlationIdAccessor) { InnerHandler = new DummyInnerHandler() }; _invoker = new HttpMessageInvoker(_underTest); _request = new HttpRequestMessage(HttpMethod.Get, "http://foo.com"); }
public async Task ShouldSkipExecutionWhenNoProviderIsRegistered() { // Arrange var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost"); var sut = new CorrelationIdHandler(); // Act var result = await InvokeAsync(sut, request); // Assert result.Should().BeEquivalentTo(request); }
public async Task ShouldSkipExecutionWhenCorrelationIdIsNotProvided() { // Arrange var correlationIdProvider = A.Fake <ICorrelationIdProvider>(); A.CallTo(() => correlationIdProvider.GetCorrelationId()) .Returns(null); var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost"); var sut = new CorrelationIdHandler(correlationIdProvider); // Act var result = await InvokeAsync(sut, request); // Assert result.RequestUri?.Query.Should().BeNullOrEmpty(); }
public async Task ShouldAddCorrelationIdAsQueryParameterWhenProvided() { // Arrange const string correlationId = "myCorrelationId"; var correlationIdProvider = A.Fake <ICorrelationIdProvider>(); A.CallTo(() => correlationIdProvider.GetCorrelationId()) .Returns(correlationId); var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost"); var sut = new CorrelationIdHandler(correlationIdProvider); // Act var result = await InvokeAsync(sut, request); // Assert result.RequestUri?.Query.Should().Contain($"tag={correlationId}"); }