-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #389 from Particular/backport-4.2.1
* Force transaction mode to receive only to allow outbox to be used * Add acceptance test
- Loading branch information
Showing
4 changed files
with
61 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/NServiceBus.AzureFunctions.Worker.ServiceBus.Tests/When_outbox_is_enabled.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
namespace ServiceBus.Tests | ||
{ | ||
using System.Threading.Tasks; | ||
using NServiceBus; | ||
using NServiceBus.AcceptanceTesting; | ||
using NUnit.Framework; | ||
|
||
public class When_outbox_is_enabled | ||
{ | ||
[Test] | ||
public async Task Should_work() | ||
{ | ||
var context = await Scenario.Define<Context>() | ||
.WithComponent(new OutboxEnabledFunction(new SomeMessage())) | ||
.Done(c => c.GotTheMessage) | ||
.Run(); | ||
|
||
Assert.True(context.GotTheMessage); | ||
} | ||
|
||
public class Context : ScenarioContext | ||
{ | ||
public bool GotTheMessage { get; set; } | ||
} | ||
|
||
class OutboxEnabledFunction : FunctionEndpointComponent | ||
{ | ||
public OutboxEnabledFunction(object triggerMessage) | ||
{ | ||
CustomizeConfiguration = configuration => | ||
{ | ||
configuration.AdvancedConfiguration.UsePersistence<AcceptanceTestingPersistence>(); | ||
configuration.AdvancedConfiguration.EnableOutbox(); | ||
}; | ||
AddTestMessage(triggerMessage); | ||
} | ||
|
||
public class SomeMessageHandler : IHandleMessages<SomeMessage> | ||
{ | ||
Context testContext; | ||
|
||
public SomeMessageHandler(Context testContext) | ||
{ | ||
this.testContext = testContext; | ||
} | ||
|
||
public Task Handle(SomeMessage message, IMessageHandlerContext context) | ||
{ | ||
testContext.GotTheMessage = true; | ||
return Task.CompletedTask; | ||
} | ||
} | ||
} | ||
|
||
class SomeMessage : IMessage | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters