From 3ad93aa9ab7e61f9f19ff41f30b3c956e8131968 Mon Sep 17 00:00:00 2001 From: Eric Sibly Date: Wed, 25 Sep 2024 10:51:03 -0700 Subject: [PATCH] v3.25.5 - *Fixed:* Fixed the unit testing `CreateServiceBusMessage` extension method so that it no longer invokes a `TesterBase.ResetHost` (this reset should now be invoked explicitly by the developer as required). --- CHANGELOG.md | 3 +++ Common.targets | 2 +- .../ServiceBus/ServiceBusSubscriberInvoker.cs | 9 +++++++++ src/CoreEx.UnitTesting/UnitTestExExtensions.cs | 4 ++-- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 324b4b1d..c4059763 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ Represents the **NuGet** versions. +## v3.25.5 +- *Fixed:* Fixed the unit testing `CreateServiceBusMessage` extension method so that it no longer invokes a `TesterBase.ResetHost` (this reset should now be invoked explicitly by the developer as required). + ## v3.25.4 - *Fixed*: Fixed the `InvalidOperationException` with a 'Sequence contains no elements' when performing validation with the `CompareValuesRule` that has the `OverrideValue` set. - *Fixed:* Updated all dependencies to latest versions. diff --git a/Common.targets b/Common.targets index fec8746d..fc5a96f1 100644 --- a/Common.targets +++ b/Common.targets @@ -1,6 +1,6 @@  - 3.25.4 + 3.25.5 preview Avanade Avanade diff --git a/src/CoreEx.Azure/ServiceBus/ServiceBusSubscriberInvoker.cs b/src/CoreEx.Azure/ServiceBus/ServiceBusSubscriberInvoker.cs index 1ee89ca2..d0e9aa44 100644 --- a/src/CoreEx.Azure/ServiceBus/ServiceBusSubscriberInvoker.cs +++ b/src/CoreEx.Azure/ServiceBus/ServiceBusSubscriberInvoker.cs @@ -34,6 +34,9 @@ protected async override Task OnInvokeAsync(InvokeArgs invokeA if (args.MessageActions == null) throw new ArgumentException($"The {nameof(ServiceBusMessageActions)} value is required.", nameof(args)); + var stopwatch = invoker.Logger.IsEnabled(LogLevel.Debug) ? System.Diagnostics.Stopwatch.StartNew() : null; + invoker.Logger.LogDebug("ServiceBusSubscriber start."); + if (!string.IsNullOrEmpty(args.Message.CorrelationId)) invoker.ExecutionContext.CorrelationId = args.Message.CorrelationId; @@ -66,6 +69,12 @@ protected async override Task OnInvokeAsync(InvokeArgs invokeA } finally { + if (stopwatch is not null) + { + stopwatch.Stop(); + invoker.Logger.LogDebug("ServiceBusSubscriber elapsed {Elapsed}ms.", stopwatch.Elapsed.TotalMilliseconds); + } + scope?.Dispose(); } } diff --git a/src/CoreEx.UnitTesting/UnitTestExExtensions.cs b/src/CoreEx.UnitTesting/UnitTestExExtensions.cs index 5b01eca8..8f10a23d 100644 --- a/src/CoreEx.UnitTesting/UnitTestExExtensions.cs +++ b/src/CoreEx.UnitTesting/UnitTestExExtensions.cs @@ -555,11 +555,11 @@ void rm(HttpRequestMessage hr) /// The tester. /// The or value. /// The . + /// This will result in the from the underlying host being instantiated. If a Services-related error occurs then consider performing a after creation to reset. public static ServiceBusReceivedMessage CreateServiceBusMessage(this TesterBase tester, EventData @event) where TSelf : TesterBase { @event.ThrowIfNull(nameof(@event)); var message = (tester.Services.GetService() ?? new EventDataToServiceBusConverter(tester.Services.GetService(), tester.Services.GetService>())).Convert(@event).GetRawAmqpMessage(); - tester.ResetHost(false); return tester.CreateServiceBusMessage(message); } @@ -571,11 +571,11 @@ public static ServiceBusReceivedMessage CreateServiceBusMessage(this Test /// The or value. /// Optional modifier than enables the message to be further configured. /// The . + /// This will result in the from the underlying host being instantiated. If a Services-related error occurs then consider performing a after creation to reset. public static ServiceBusReceivedMessage CreateServiceBusMessage(this TesterBase tester, EventData @event, Action? messageModify) where TSelf : TesterBase { @event.ThrowIfNull(nameof(@event)); var message = (tester.Services.GetService() ?? new EventDataToServiceBusConverter(tester.Services.GetService(), tester.Services.GetService>())).Convert(@event).GetRawAmqpMessage(); - tester.ResetHost(false); return tester.CreateServiceBusMessage(message, messageModify); }