-
-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add repro for event forwarding routing bug
- Loading branch information
1 parent
dda0488
commit be16b98
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
src/Persistence/MartenTests/Bugs/event_forwarding_routing_bug.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,66 @@ | ||
using IntegrationTests; | ||
using Marten; | ||
using Marten.Events; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using Shouldly; | ||
using Wolverine; | ||
using Wolverine.Marten; | ||
|
||
namespace MartenTests.Bugs; | ||
|
||
public class event_forwarding_routing_bug | ||
{ | ||
[Fact] | ||
public async Task forwarded_events_respects_routing_rules() | ||
{ | ||
using var host = await Host.CreateDefaultBuilder() | ||
.UseWolverine(opts => | ||
{ | ||
opts.PublishAllMessages().ToLocalQueue("forwarded-events"); | ||
opts.Services.AddMarten(m => | ||
{ | ||
m.Connection(Servers.PostgresConnectionString); | ||
m.DatabaseSchemaName = "forwarding_routing"; | ||
}) | ||
.IntegrateWithWolverine() | ||
.EventForwardingToWolverine(); | ||
}) | ||
.StartAsync(); | ||
|
||
var bus = host.Services.GetRequiredService<IMessageBus>(); | ||
bus.PreviewSubscriptions(new Event<SomeEvent>(new SomeEvent())) | ||
.ShouldAllBe(x => x.Destination == new Uri("local://forwarded-events")); | ||
} | ||
|
||
[Fact] | ||
public async Task subscription_events_respects_routing_rules() | ||
{ | ||
using var host = await Host.CreateDefaultBuilder() | ||
.UseWolverine(opts => | ||
{ | ||
opts.PublishAllMessages().ToLocalQueue("forwarded-events"); | ||
opts.Services.AddMarten(m => | ||
{ | ||
m.Connection(Servers.PostgresConnectionString); | ||
m.DatabaseSchemaName = "forwarding_routing"; | ||
}) | ||
.IntegrateWithWolverine() | ||
.PublishEventsToWolverine("forwarded-events"); | ||
}) | ||
.StartAsync(); | ||
|
||
var bus = host.Services.GetRequiredService<IMessageBus>(); | ||
bus.PreviewSubscriptions(new Event<SomeEvent>(new SomeEvent())) | ||
.ShouldAllBe(x => x.Destination == new Uri("local://forwarded-events")); | ||
} | ||
|
||
public record SomeEvent; | ||
|
||
public static class SomeEventHandler | ||
{ | ||
public static void Handle(IEvent<SomeEvent> _) | ||
{ | ||
} | ||
} | ||
} |