Skip to content

Commit

Permalink
Removed unittest that are not needed anymore.
Browse files Browse the repository at this point in the history
  • Loading branch information
Roeland Lutters authored and Roeland Lutters committed Mar 9, 2023
1 parent 864461c commit 798833e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -435,119 +435,6 @@ public async Task SendRequest_WithCorrelateOptionsUpstreamServiceExtractFromRequ
}
}

[Theory]
[InlineData(false)]
[InlineData(true)]
public async Task SendRequest_WithCorrelateOptionsOperationParentExtractFromRequest_UsesUpstreamOperationId(bool extractFromRequest)
{
// Arrange
var operationParentId = Guid.NewGuid().ToString();
var requestId = $"|{Guid.NewGuid()}.{operationParentId}";
var options = new TestApiServerOptions()
.ConfigureServices(services => services.AddHttpCorrelation(opt =>
{
opt.OperationParent.ExtractFromRequest = extractFromRequest;
}))
.PreConfigure(app => app.UseHttpCorrelation());

await using (var server = await TestApiServer.StartNewAsync(options, _logger))
{
var request = HttpRequestBuilder
.Get(CorrelationController.GetRoute)
.WithHeader(DefaultOperationParentId, requestId);

// Act
using (HttpResponseMessage response = await server.SendAsync(request))
{
// Assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
string responseRequestId = GetResponseHeader(response, DefaultOperationParentId);

CorrelationInfo correlation = await ReadCorrelationInfoFromResponseBodyAsync(response);
Assert.Equal(correlation.OperationId, GetResponseHeader(response, DefaultOperationId));
Assert.Equal(correlation.TransactionId, GetResponseHeader(response, DefaultTransactionId));
Assert.Equal(extractFromRequest, operationParentId == correlation.OperationParentId);
Assert.Equal(extractFromRequest, requestId == responseRequestId);
}
}
}

[Theory]
[InlineData(false, "|abc.def", null)]
[InlineData(true, "|abc.def", "def")]
[InlineData(false, "abc", null)]
[InlineData(true, "abc", "abc")]
public async Task SendRequest_WithCorrelateOptionsOperationParentExtractFromRequest_UsesRequestId(bool extractFromRequest, string requestId, string expectedParentId)
{
// Arrange
var options = new TestApiServerOptions()
.ConfigureServices(services => services.AddHttpCorrelation(opt =>
{
opt.OperationParent.ExtractFromRequest = extractFromRequest;
}))
.PreConfigure(app => app.UseHttpCorrelation());

await using (var server = await TestApiServer.StartNewAsync(options, _logger))
{
var request = HttpRequestBuilder
.Get(CorrelationController.GetRoute)
.WithHeader(DefaultOperationParentId, requestId);

// Act
using (HttpResponseMessage response = await server.SendAsync(request))
{
// Assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
string responseRequestId = GetResponseHeader(response, DefaultOperationParentId);

CorrelationInfo correlation = await ReadCorrelationInfoFromResponseBodyAsync(response);
Assert.Equal(correlation.OperationId, GetResponseHeader(response, DefaultOperationId));
Assert.Equal(correlation.TransactionId, GetResponseHeader(response, DefaultTransactionId));
Assert.Equal(extractFromRequest, expectedParentId == correlation.OperationParentId);
Assert.Equal(extractFromRequest, requestId == responseRequestId);
}
}
}

[Theory]
[InlineData(false)]
[InlineData(true)]
public async Task SendRequest_WithCorrelateOptionsOperationParentCustomOperationParentIHeaderName_UsesUpstreamOperationId(bool extractFromRequest)
{
// Arrange
var operationParentId = Guid.NewGuid().ToString();
var requestId = $"|{Guid.NewGuid()}.{operationParentId}";
var operationParentIdHeaderName = "My-Request-Id";
var options = new TestApiServerOptions()
.ConfigureServices(services => services.AddHttpCorrelation(opt =>
{
opt.OperationParent.ExtractFromRequest = extractFromRequest;
opt.OperationParent.OperationParentIdHeaderName = operationParentIdHeaderName;
}))
.PreConfigure(app => app.UseHttpCorrelation());

await using (var server = await TestApiServer.StartNewAsync(options, _logger))
{
var request = HttpRequestBuilder
.Get(CorrelationController.GetRoute)
.WithHeader(operationParentIdHeaderName, requestId);

// Act
using (HttpResponseMessage response = await server.SendAsync(request))
{
// Assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
string responseRequestId = GetResponseHeader(response, operationParentIdHeaderName);

CorrelationInfo correlation = await ReadCorrelationInfoFromResponseBodyAsync(response);
Assert.Equal(correlation.OperationId, GetResponseHeader(response, DefaultOperationId));
Assert.Equal(correlation.TransactionId, GetResponseHeader(response, DefaultTransactionId));
Assert.Equal(extractFromRequest, operationParentId == correlation.OperationParentId);
Assert.Equal(extractFromRequest, responseRequestId == requestId);
}
}
}

[Theory]
[InlineData(false)]
[InlineData(true)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Arcus.Observability.Correlation;
#if NET6_0
using Arcus.WebApi.Logging.Core.Correlation;
Expand All @@ -15,24 +12,6 @@ namespace Arcus.WebApi.Tests.Unit.Logging
// ReSharper disable once InconsistentNaming
public class IServiceCollectionExtensionsTests
{
[Fact]
public void AddHttpCorrelation_WithOptions_RegistersDedicatedCorrelation()
{
// Arrange
var services = new ServiceCollection();

// Act
#pragma warning disable CS0618 // Type or member is obsolete
services.AddHttpCorrelation((Action<CorrelationInfoOptions>) null);
#pragma warning restore CS0618 // Type or member is obsolete

// Assert
IServiceProvider provider = services.BuildServiceProvider();
Assert.NotNull(provider.GetService<IHttpCorrelationInfoAccessor>());
Assert.NotNull(provider.GetService<ICorrelationInfoAccessor<CorrelationInfo>>());
Assert.NotNull(provider.GetService<ICorrelationInfoAccessor>());
}

[Fact]
public void AddHttpCorrelation_WithHttpOptions_RegistersDedicatedCorrelation()
{
Expand Down

0 comments on commit 798833e

Please sign in to comment.