From 798833e40b38008de14c76a9dd8e52664ce16bee Mon Sep 17 00:00:00 2001 From: Roeland Lutters Date: Thu, 9 Mar 2023 13:38:33 +0100 Subject: [PATCH] Removed unittest that are not needed anymore. --- .../HierarchicalCorrelationMiddlewareTests.cs | 113 ------------------ .../IServiceCollectionExtensionsTests.cs | 21 ---- 2 files changed, 134 deletions(-) diff --git a/src/Arcus.WebApi.Tests.Integration/Logging/HierarchicalCorrelationMiddlewareTests.cs b/src/Arcus.WebApi.Tests.Integration/Logging/HierarchicalCorrelationMiddlewareTests.cs index 48dd0ee7..21d04fc6 100644 --- a/src/Arcus.WebApi.Tests.Integration/Logging/HierarchicalCorrelationMiddlewareTests.cs +++ b/src/Arcus.WebApi.Tests.Integration/Logging/HierarchicalCorrelationMiddlewareTests.cs @@ -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)] diff --git a/src/Arcus.WebApi.Tests.Unit/Logging/IServiceCollectionExtensionsTests.cs b/src/Arcus.WebApi.Tests.Unit/Logging/IServiceCollectionExtensionsTests.cs index 922c6e8d..5c5e6d34 100644 --- a/src/Arcus.WebApi.Tests.Unit/Logging/IServiceCollectionExtensionsTests.cs +++ b/src/Arcus.WebApi.Tests.Unit/Logging/IServiceCollectionExtensionsTests.cs @@ -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; @@ -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) null); -#pragma warning restore CS0618 // Type or member is obsolete - - // Assert - IServiceProvider provider = services.BuildServiceProvider(); - Assert.NotNull(provider.GetService()); - Assert.NotNull(provider.GetService>()); - Assert.NotNull(provider.GetService()); - } - [Fact] public void AddHttpCorrelation_WithHttpOptions_RegistersDedicatedCorrelation() {