NServiceBus.Extensions.IntegrationTesting icon indicating copy to clipboard operation
NServiceBus.Extensions.IntegrationTesting copied to clipboard

Version 3.0.0 doesn't properly handle Published events in ExecuteAndWaitForSent method

Open pelikak opened this issue 8 months ago • 2 comments

Hello @jbogard!

I have a problem with v3.0.0 of this package (I am using NServiceBus v8.0.0). The ExecuteAndWaitForSent doesn't properly handle published events. I suppose there is a missing case in ExecuteAndWait method. For now I created workaround adding ExecuteAndWaitForPublish method with the missing bit:

case "NServiceBus.Diagnostics.PublishMessage":
    var outgoingContext = activitySource.GetTagItem("testing.outgoing.message.context") as IOutgoingLogicalMessageContext;

    outgoingMessageContexts.Add(outgoingContext);

    if (outgoingContext is TMessageContext ctx2 && predicate(ctx2))
    {
        messageReceivingTaskSource.SetResult(null);
    }

    break;

It would be great if you find a time to fix it.

Thanks!

pelikak avatar May 30 '25 11:05 pelikak