Skip to content

Commit

Permalink
Addressing some routing logic bugs in the fluent interface. Closes GH…
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydmiller committed Oct 27, 2024
1 parent 32f9ec9 commit f7d7c29
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Diagnostics;
using JasperFx.Core.Reflection;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Module2;
using Wolverine.ComplianceTests;
using Wolverine.Attributes;
using Wolverine.Configuration;
Expand All @@ -13,7 +15,7 @@

namespace CoreTests.Runtime.Routing;

public class routing_precedence
public class routing_rules
{
[Fact]
public async Task local_routing_is_applied_automatically()
Expand Down Expand Up @@ -206,6 +208,25 @@ public async Task use_no_handler_if_no_handler_and_no_subscriber()
collection.FindInvoker(typeof(RedMessage))
.ShouldBeOfType<NoHandlerExecutor>();
}

// This one is for https://github.com/JasperFx/wolverine/issues/1099
[Fact]
public async Task route_with_fluent_interface()
{
var port = PortFinder.GetAvailablePort();
using var host = await Host.CreateDefaultBuilder()
.UseWolverine(opts =>
{
//opts.Discovery.IncludeAssembly(typeof(Module2Message1).Assembly);
opts.Publish().MessagesFromAssembly(typeof(Module2Message1).Assembly).ToPort(port);
}).StartAsync();

var bus = host.MessageBus();
var envelopes = bus.PreviewSubscriptions(new Module2Message1());

envelopes.Single().Destination.ShouldBe(new Uri("tcp://localhost:" + port));
}
}

public class ColorsMessageHandler
Expand Down
3 changes: 3 additions & 0 deletions src/Wolverine/Configuration/PublishingExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ public PublishingExpression Message(Type type)
/// <returns></returns>
public PublishingExpression MessagesFromNamespace(string @namespace)
{
AutoAddSubscriptions = true;

_subscriptions.Add(new Subscription
{
Match = @namespace,
Expand Down Expand Up @@ -144,6 +146,7 @@ public PublishingExpression MessagesFromNamespaceContaining<T>()
public PublishingExpression MessagesFromAssembly(Assembly assembly)
{
_subscriptions.Add(new Subscription(assembly));
AutoAddSubscriptions = true;
return this;
}

Expand Down

0 comments on commit f7d7c29

Please sign in to comment.