Skip to content

Commit

Permalink
Fix pipeline approval tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bording committed Jan 28, 2022
1 parent 4cacce7 commit f74b2fc
Show file tree
Hide file tree
Showing 11 changed files with 172 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
context0 => Convert(context0.Extensions.Behaviors[0], EnforcePublishBestPracticesBehavior).Invoke(context0, value(System.Func`2[NServiceBus.Pipeline.IOutgoingPublishContext,System.Threading.Tasks.Task])),
context1 => Convert(context1.Extensions.Behaviors[1], UnicastPublishConnector).Invoke(context1, value(System.Func`2[NServiceBus.Pipeline.IOutgoingLogicalMessageContext,System.Threading.Tasks.Task])),
context2 => Convert(context2.Extensions.Behaviors[2], AttachCausationHeadersBehavior).Invoke(context2, value(System.Func`2[NServiceBus.Pipeline.IOutgoingLogicalMessageContext,System.Threading.Tasks.Task])),
context3 => Convert(context3.Extensions.Behaviors[3], AttachCorrelationIdBehavior).Invoke(context3, value(System.Func`2[NServiceBus.Pipeline.IOutgoingLogicalMessageContext,System.Threading.Tasks.Task])),
context4 => Convert(context4.Extensions.Behaviors[4], MutateOutgoingMessageBehavior).Invoke(context4, value(System.Func`2[NServiceBus.Pipeline.IOutgoingLogicalMessageContext,System.Threading.Tasks.Task])),
context5 => Convert(context5.Extensions.Behaviors[5], ApplyTimeToBeReceivedBehavior).Invoke(context5, value(System.Func`2[NServiceBus.Pipeline.IOutgoingLogicalMessageContext,System.Threading.Tasks.Task])),
context6 => Convert(context6.Extensions.Behaviors[6], ApplyReplyToAddressBehavior).Invoke(context6, value(System.Func`2[NServiceBus.Pipeline.IOutgoingLogicalMessageContext,System.Threading.Tasks.Task])),
context7 => Convert(context7.Extensions.Behaviors[7], AddHostInfoHeadersBehavior).Invoke(context7, value(System.Func`2[NServiceBus.Pipeline.IOutgoingLogicalMessageContext,System.Threading.Tasks.Task])),
context8 => Convert(context8.Extensions.Behaviors[8], SerializeMessageConnector).Invoke(context8, value(System.Func`2[NServiceBus.Pipeline.IOutgoingPhysicalMessageContext,System.Threading.Tasks.Task])),
context9 => Convert(context9.Extensions.Behaviors[9], MutateOutgoingTransportMessageBehavior).Invoke(context9, value(System.Func`2[NServiceBus.Pipeline.IOutgoingPhysicalMessageContext,System.Threading.Tasks.Task])),
context10 => Convert(context10.Extensions.Behaviors[10], OutgoingPhysicalToRoutingConnector).Invoke(context10, value(System.Func`2[NServiceBus.Pipeline.IRoutingContext,System.Threading.Tasks.Task])),
context11 => Convert(context11.Extensions.Behaviors[11], ThrowIfCannotDeferMessageBehavior).Invoke(context11, value(System.Func`2[NServiceBus.Pipeline.IRoutingContext,System.Threading.Tasks.Task])),
context12 => Convert(context12.Extensions.Behaviors[12], AttachSenderRelatedInfoOnMessageBehavior).Invoke(context12, value(System.Func`2[NServiceBus.Pipeline.IRoutingContext,System.Threading.Tasks.Task])),
context13 => Convert(context13.Extensions.Behaviors[13], RoutingToDispatchConnector).Invoke(context13, value(System.Func`2[NServiceBus.Pipeline.IDispatchContext,System.Threading.Tasks.Task])),
context14 => Convert(context14.Extensions.Behaviors[14], ImmediateDispatchTerminator).Invoke(context14, value(System.Func`2[NServiceBus.Pipeline.PipelineTerminator`1+ITerminatingContext[NServiceBus.Pipeline.IDispatchContext],System.Threading.Tasks.Task])),

context0 => Convert(context0.Extensions.Behaviors[0], EnforceSendBestPracticesBehavior).Invoke(context0, value(System.Func`2[NServiceBus.Pipeline.IOutgoingSendContext,System.Threading.Tasks.Task])),
context1 => Convert(context1.Extensions.Behaviors[1], SendConnector).Invoke(context1, value(System.Func`2[NServiceBus.Pipeline.IOutgoingLogicalMessageContext,System.Threading.Tasks.Task])),
context2 => Convert(context2.Extensions.Behaviors[2], AttachCausationHeadersBehavior).Invoke(context2, value(System.Func`2[NServiceBus.Pipeline.IOutgoingLogicalMessageContext,System.Threading.Tasks.Task])),
context3 => Convert(context3.Extensions.Behaviors[3], AttachCorrelationIdBehavior).Invoke(context3, value(System.Func`2[NServiceBus.Pipeline.IOutgoingLogicalMessageContext,System.Threading.Tasks.Task])),
context4 => Convert(context4.Extensions.Behaviors[4], MutateOutgoingMessageBehavior).Invoke(context4, value(System.Func`2[NServiceBus.Pipeline.IOutgoingLogicalMessageContext,System.Threading.Tasks.Task])),
context5 => Convert(context5.Extensions.Behaviors[5], ApplyTimeToBeReceivedBehavior).Invoke(context5, value(System.Func`2[NServiceBus.Pipeline.IOutgoingLogicalMessageContext,System.Threading.Tasks.Task])),
context6 => Convert(context6.Extensions.Behaviors[6], ApplyReplyToAddressBehavior).Invoke(context6, value(System.Func`2[NServiceBus.Pipeline.IOutgoingLogicalMessageContext,System.Threading.Tasks.Task])),
context7 => Convert(context7.Extensions.Behaviors[7], AddHostInfoHeadersBehavior).Invoke(context7, value(System.Func`2[NServiceBus.Pipeline.IOutgoingLogicalMessageContext,System.Threading.Tasks.Task])),
context8 => Convert(context8.Extensions.Behaviors[8], SerializeMessageConnector).Invoke(context8, value(System.Func`2[NServiceBus.Pipeline.IOutgoingPhysicalMessageContext,System.Threading.Tasks.Task])),
context9 => Convert(context9.Extensions.Behaviors[9], MutateOutgoingTransportMessageBehavior).Invoke(context9, value(System.Func`2[NServiceBus.Pipeline.IOutgoingPhysicalMessageContext,System.Threading.Tasks.Task])),
context10 => Convert(context10.Extensions.Behaviors[10], OutgoingPhysicalToRoutingConnector).Invoke(context10, value(System.Func`2[NServiceBus.Pipeline.IRoutingContext,System.Threading.Tasks.Task])),
context11 => Convert(context11.Extensions.Behaviors[11], ThrowIfCannotDeferMessageBehavior).Invoke(context11, value(System.Func`2[NServiceBus.Pipeline.IRoutingContext,System.Threading.Tasks.Task])),
context12 => Convert(context12.Extensions.Behaviors[12], AttachSenderRelatedInfoOnMessageBehavior).Invoke(context12, value(System.Func`2[NServiceBus.Pipeline.IRoutingContext,System.Threading.Tasks.Task])),
context13 => Convert(context13.Extensions.Behaviors[13], RoutingToDispatchConnector).Invoke(context13, value(System.Func`2[NServiceBus.Pipeline.IDispatchContext,System.Threading.Tasks.Task])),
context14 => Convert(context14.Extensions.Behaviors[14], ImmediateDispatchTerminator).Invoke(context14, value(System.Func`2[NServiceBus.Pipeline.PipelineTerminator`1+ITerminatingContext[NServiceBus.Pipeline.IDispatchContext],System.Threading.Tasks.Task])),

context0 => Convert(context0.Extensions.Behaviors[0], PopulateAutoCorrelationHeadersForRepliesBehavior).Invoke(context0, value(System.Func`2[NServiceBus.Pipeline.IOutgoingReplyContext,System.Threading.Tasks.Task])),
context1 => Convert(context1.Extensions.Behaviors[1], EnforceReplyBestPracticesBehavior).Invoke(context1, value(System.Func`2[NServiceBus.Pipeline.IOutgoingReplyContext,System.Threading.Tasks.Task])),
context2 => Convert(context2.Extensions.Behaviors[2], ReplyConnector).Invoke(context2, value(System.Func`2[NServiceBus.Pipeline.IOutgoingLogicalMessageContext,System.Threading.Tasks.Task])),
context3 => Convert(context3.Extensions.Behaviors[3], AttachCausationHeadersBehavior).Invoke(context3, value(System.Func`2[NServiceBus.Pipeline.IOutgoingLogicalMessageContext,System.Threading.Tasks.Task])),
context4 => Convert(context4.Extensions.Behaviors[4], AttachCorrelationIdBehavior).Invoke(context4, value(System.Func`2[NServiceBus.Pipeline.IOutgoingLogicalMessageContext,System.Threading.Tasks.Task])),
context5 => Convert(context5.Extensions.Behaviors[5], MutateOutgoingMessageBehavior).Invoke(context5, value(System.Func`2[NServiceBus.Pipeline.IOutgoingLogicalMessageContext,System.Threading.Tasks.Task])),
context6 => Convert(context6.Extensions.Behaviors[6], ApplyTimeToBeReceivedBehavior).Invoke(context6, value(System.Func`2[NServiceBus.Pipeline.IOutgoingLogicalMessageContext,System.Threading.Tasks.Task])),
context7 => Convert(context7.Extensions.Behaviors[7], ApplyReplyToAddressBehavior).Invoke(context7, value(System.Func`2[NServiceBus.Pipeline.IOutgoingLogicalMessageContext,System.Threading.Tasks.Task])),
context8 => Convert(context8.Extensions.Behaviors[8], AddHostInfoHeadersBehavior).Invoke(context8, value(System.Func`2[NServiceBus.Pipeline.IOutgoingLogicalMessageContext,System.Threading.Tasks.Task])),
context9 => Convert(context9.Extensions.Behaviors[9], SerializeMessageConnector).Invoke(context9, value(System.Func`2[NServiceBus.Pipeline.IOutgoingPhysicalMessageContext,System.Threading.Tasks.Task])),
context10 => Convert(context10.Extensions.Behaviors[10], MutateOutgoingTransportMessageBehavior).Invoke(context10, value(System.Func`2[NServiceBus.Pipeline.IOutgoingPhysicalMessageContext,System.Threading.Tasks.Task])),
context11 => Convert(context11.Extensions.Behaviors[11], OutgoingPhysicalToRoutingConnector).Invoke(context11, value(System.Func`2[NServiceBus.Pipeline.IRoutingContext,System.Threading.Tasks.Task])),
context12 => Convert(context12.Extensions.Behaviors[12], ThrowIfCannotDeferMessageBehavior).Invoke(context12, value(System.Func`2[NServiceBus.Pipeline.IRoutingContext,System.Threading.Tasks.Task])),
context13 => Convert(context13.Extensions.Behaviors[13], AttachSenderRelatedInfoOnMessageBehavior).Invoke(context13, value(System.Func`2[NServiceBus.Pipeline.IRoutingContext,System.Threading.Tasks.Task])),
context14 => Convert(context14.Extensions.Behaviors[14], RoutingToDispatchConnector).Invoke(context14, value(System.Func`2[NServiceBus.Pipeline.IDispatchContext,System.Threading.Tasks.Task])),
context15 => Convert(context15.Extensions.Behaviors[15], ImmediateDispatchTerminator).Invoke(context15, value(System.Func`2[NServiceBus.Pipeline.PipelineTerminator`1+ITerminatingContext[NServiceBus.Pipeline.IDispatchContext],System.Threading.Tasks.Task])),

context0 => Convert(context0.Extensions.Behaviors[0], EnforceSubscribeBestPracticesBehavior).Invoke(context0, value(System.Func`2[NServiceBus.Pipeline.ISubscribeContext,System.Threading.Tasks.Task])),
context1 => Convert(context1.Extensions.Behaviors[1], MessageDrivenSubscribeTerminator).Invoke(context1, value(System.Func`2[NServiceBus.Pipeline.PipelineTerminator`1+ITerminatingContext[NServiceBus.Pipeline.ISubscribeContext],System.Threading.Tasks.Task])),

context0 => Convert(context0.Extensions.Behaviors[0], EnforceUnsubscribeBestPracticesBehavior).Invoke(context0, value(System.Func`2[NServiceBus.Pipeline.IUnsubscribeContext,System.Threading.Tasks.Task])),
context1 => Convert(context1.Extensions.Behaviors[1], MessageDrivenUnsubscribeTerminator).Invoke(context1, value(System.Func`2[NServiceBus.Pipeline.PipelineTerminator`1+ITerminatingContext[NServiceBus.Pipeline.IUnsubscribeContext],System.Threading.Tasks.Task])),

context0 => Convert(context0.Extensions.Behaviors[0], CaptureExceptionBehavior).Invoke(context0, value(System.Func`2[NServiceBus.Pipeline.ITransportReceiveContext,System.Threading.Tasks.Task])),
context1 => Convert(context1.Extensions.Behaviors[1], RetryAcknowledgementBehavior).Invoke(context1, value(System.Func`2[NServiceBus.Pipeline.ITransportReceiveContext,System.Threading.Tasks.Task])),
context2 => Convert(context2.Extensions.Behaviors[2], TransportReceiveToPhysicalMessageConnector).Invoke(context2, value(System.Func`2[NServiceBus.Pipeline.IIncomingPhysicalMessageContext,System.Threading.Tasks.Task])),
context3 => Convert(context3.Extensions.Behaviors[3], ProcessingStatisticsBehavior).Invoke(context3, value(System.Func`2[NServiceBus.Pipeline.IIncomingPhysicalMessageContext,System.Threading.Tasks.Task])),
context4 => Convert(context4.Extensions.Behaviors[4], MutateIncomingTransportMessageBehavior).Invoke(context4, value(System.Func`2[NServiceBus.Pipeline.IIncomingPhysicalMessageContext,System.Threading.Tasks.Task])),
context5 => Convert(context5.Extensions.Behaviors[5], SubscriptionReceiverBehavior).Invoke(context5, value(System.Func`2[NServiceBus.Pipeline.IIncomingPhysicalMessageContext,System.Threading.Tasks.Task])),
context6 => Convert(context6.Extensions.Behaviors[6], UnitOfWorkBehavior).Invoke(context6, value(System.Func`2[NServiceBus.Pipeline.IIncomingPhysicalMessageContext,System.Threading.Tasks.Task])),
context7 => Convert(context7.Extensions.Behaviors[7], DeserializeMessageConnector).Invoke(context7, value(System.Func`2[NServiceBus.Pipeline.IIncomingLogicalMessageContext,System.Threading.Tasks.Task])),
context8 => Convert(context8.Extensions.Behaviors[8], MutateIncomingMessageBehavior).Invoke(context8, value(System.Func`2[NServiceBus.Pipeline.IIncomingLogicalMessageContext,System.Threading.Tasks.Task])),
context9 => Convert(context9.Extensions.Behaviors[9], InferredMessageTypeEnricherBehavior).Invoke(context9, value(System.Func`2[NServiceBus.Pipeline.IIncomingLogicalMessageContext,System.Threading.Tasks.Task])),
context10 => Convert(context10.Extensions.Behaviors[10], LoadHandlersConnector).Invoke(context10, value(System.Func`2[NServiceBus.Pipeline.IInvokeHandlerContext,System.Threading.Tasks.Task])),
context11 => Convert(context11.Extensions.Behaviors[11], InvokeHandlerTerminator).Invoke(context11, value(System.Func`2[NServiceBus.Pipeline.PipelineTerminator`1+ITerminatingContext[NServiceBus.Pipeline.IInvokeHandlerContext],System.Threading.Tasks.Task])),
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,18 @@ public async Task Should_preserve_order()
var pipelineLogs = context.Logs.Where(x => x.LoggerName.StartsWith("NServiceBus.Pipeline"))
.Distinct(LoggerNameComparer.Instance).Select(x => x.Message);

#if NET5_0_OR_GREATER
// System.Threading.Tasks.Task has changed to System.Threading.Tasks.Task`1[System.Threading.Tasks.VoidTaskResult] in .NET 5
// This ifdef is to make sure the new type is only validated for .NET 5 or greater.
var scenario = "net5";
// The output varies between TFMs, so a separate approval file is created for each framework.
// If a TFM gets added to the test project in the future, it intentionally will create a new
// "unknown" approval file, which will fail. The test should be updated to handle the new TFM.
#if NET472
var scenario = "net472";
#elif NETCOREAPP3_1
var scenario = "netcoreapp3.1";
#elif NET6_0
var scenario = "net6.0";
#else
var scenario = string.Empty;
var scenario = "unknown";
#endif

Approver.Verify(string.Join(Environment.NewLine, pipelineLogs), scenario: scenario);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
context0 => Convert(context0.Extensions.Behaviors[0]).Invoke(context0, value(System.Func`2[NServiceBus.Pipeline.IIncomingPhysicalMessageContext,System.Threading.Tasks.Task])),
context0 => Convert(context0.Extensions.Behaviors[0]).Invoke(context0, value(System.Func`2[NServiceBus.Pipeline.IIncomingPhysicalMessageContext,System.Threading.Tasks.Task])),
context1 => Convert(context1.Extensions.Behaviors[1]).Invoke(context1, value(System.Func`2[NServiceBus.Pipeline.IIncomingPhysicalMessageContext,System.Threading.Tasks.Task])),
context2 => Convert(context2.Extensions.Behaviors[2]).Invoke(context2, value(System.Func`2[NServiceBus.Pipeline.IIncomingLogicalMessageContext,System.Threading.Tasks.Task])),
context3 => Convert(context3.Extensions.Behaviors[3]).Invoke(context3, value(System.Func`2[NServiceBus.Pipeline.IIncomingLogicalMessageContext,System.Threading.Tasks.Task])),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
context0 => Convert(context0.Extensions.Behaviors[0], StageFork).Invoke(context0, value(System.Func`2[NServiceBus.Pipeline.IIncomingPhysicalMessageContext,System.Threading.Tasks.Task])),
context1 => Convert(context1.Extensions.Behaviors[1], Behavior1).Invoke(context1, value(System.Func`2[NServiceBus.Pipeline.IIncomingPhysicalMessageContext,System.Threading.Tasks.Task])),
context2 => Convert(context2.Extensions.Behaviors[2], Stage1).Invoke(context2, value(System.Func`2[NServiceBus.Pipeline.IIncomingLogicalMessageContext,System.Threading.Tasks.Task])),
context3 => Convert(context3.Extensions.Behaviors[3], Behavior2).Invoke(context3, value(System.Func`2[NServiceBus.Pipeline.IIncomingLogicalMessageContext,System.Threading.Tasks.Task])),
context4 => Convert(context4.Extensions.Behaviors[4], Stage2).Invoke(context4, value(System.Func`2[NServiceBus.Pipeline.IDispatchContext,System.Threading.Tasks.Task])),
context5 => Convert(context5.Extensions.Behaviors[5], Terminator).Invoke(context5, value(System.Func`2[NServiceBus.Pipeline.PipelineTerminator`1+ITerminatingContext[NServiceBus.Pipeline.IDispatchContext],System.Threading.Tasks.Task])),
16 changes: 10 additions & 6 deletions src/NServiceBus.Core.Tests/Pipeline/PipelineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,18 @@ public void ShouldCreateCachedExecutionPlan()
var expressions = new List<Expression>();
behaviors.CreatePipelineExecutionExpression(expressions);

#if NET5_0_OR_GREATER
// System.Threading.Tasks.Task has changed to System.Threading.Tasks.Task`1[System.Threading.Tasks.VoidTaskResult] in .NET 5
// This ifdef is to make sure the new type is only validated for .NET 5 or greater.
var scenario = "net5";
// The output varies between TFMs, so a separate approval file is created for each framework.
// If a TFM gets added to the test project in the future, it intentionally will create a new
// "unknown" approval file, which will fail. The test should be updated to handle the new TFM.
#if NET472
var scenario = "net472";
#elif NETCOREAPP3_1
var scenario = "netcoreapp3.1";
#elif NET6_0
var scenario = "net6.0";
#else
var scenario = string.Empty;
var scenario = "unknown";
#endif

Approver.Verify(expressions.PrettyPrint(), scenario: scenario);
}

Expand Down
Loading

0 comments on commit f74b2fc

Please sign in to comment.