Skip to content

Commit

Permalink
v3.25.5
Browse files Browse the repository at this point in the history
- *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).
  • Loading branch information
chullybun committed Sep 25, 2024
1 parent cdfd560 commit 3ad93aa
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Common.targets
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>3.25.4</Version>
<Version>3.25.5</Version>
<LangVersion>preview</LangVersion>
<Authors>Avanade</Authors>
<Company>Avanade</Company>
Expand Down
9 changes: 9 additions & 0 deletions src/CoreEx.Azure/ServiceBus/ServiceBusSubscriberInvoker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ protected async override Task<TResult> OnInvokeAsync<TResult>(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;

Expand Down Expand Up @@ -66,6 +69,12 @@ protected async override Task<TResult> OnInvokeAsync<TResult>(InvokeArgs invokeA
}
finally
{
if (stopwatch is not null)
{
stopwatch.Stop();
invoker.Logger.LogDebug("ServiceBusSubscriber elapsed {Elapsed}ms.", stopwatch.Elapsed.TotalMilliseconds);
}

scope?.Dispose();
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/CoreEx.UnitTesting/UnitTestExExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -555,11 +555,11 @@ void rm(HttpRequestMessage hr)
/// <param name="tester">The tester.</param>
/// <param name="event">The <see cref="EventData"/> or <see cref="EventData{T}"/> value.</param>
/// <returns>The <see cref="ServiceBusReceivedMessage"/>.</returns>
/// <remarks>This will result in the <see cref="TesterBase.Services"/> from the underlying host being instantiated. If a <b>Services</b>-related error occurs then consider performing a <see cref="TesterBase.ResetHost()"/> after creation to reset.</remarks>
public static ServiceBusReceivedMessage CreateServiceBusMessage<TSelf>(this TesterBase<TSelf> tester, EventData @event) where TSelf : TesterBase<TSelf>
{
@event.ThrowIfNull(nameof(@event));
var message = (tester.Services.GetService<EventDataToServiceBusConverter>() ?? new EventDataToServiceBusConverter(tester.Services.GetService<IEventSerializer>(), tester.Services.GetService<IValueConverter<EventSendData, ServiceBusMessage>>())).Convert(@event).GetRawAmqpMessage();
tester.ResetHost(false);
return tester.CreateServiceBusMessage(message);
}

Expand All @@ -571,11 +571,11 @@ public static ServiceBusReceivedMessage CreateServiceBusMessage<TSelf>(this Test
/// <param name="event">The <see cref="EventData"/> or <see cref="EventData{T}"/> value.</param>
/// <param name="messageModify">Optional <see cref="AmqpAnnotatedMessage"/> modifier than enables the message to be further configured.</param>
/// <returns>The <see cref="ServiceBusReceivedMessage"/>.</returns>
/// <remarks>This will result in the <see cref="TesterBase.Services"/> from the underlying host being instantiated. If a <b>Services</b>-related error occurs then consider performing a <see cref="TesterBase.ResetHost()"/> after creation to reset.</remarks>
public static ServiceBusReceivedMessage CreateServiceBusMessage<TSelf>(this TesterBase<TSelf> tester, EventData @event, Action<AmqpAnnotatedMessage>? messageModify) where TSelf : TesterBase<TSelf>
{
@event.ThrowIfNull(nameof(@event));
var message = (tester.Services.GetService<EventDataToServiceBusConverter>() ?? new EventDataToServiceBusConverter(tester.Services.GetService<IEventSerializer>(), tester.Services.GetService<IValueConverter<EventSendData, ServiceBusMessage>>())).Convert(@event).GetRawAmqpMessage();
tester.ResetHost(false);
return tester.CreateServiceBusMessage(message, messageModify);
}

Expand Down

0 comments on commit 3ad93aa

Please sign in to comment.