diff --git a/src/Transports/RabbitMQ/Wolverine.RabbitMQ.Tests/end_to_end.cs b/src/Transports/RabbitMQ/Wolverine.RabbitMQ.Tests/end_to_end.cs index 2cc9e1dfc..c9bc3b53a 100644 --- a/src/Transports/RabbitMQ/Wolverine.RabbitMQ.Tests/end_to_end.cs +++ b/src/Transports/RabbitMQ/Wolverine.RabbitMQ.Tests/end_to_end.cs @@ -62,6 +62,35 @@ public void rabbitmq_transport_is_exposed_as_a_resource() publisher.Services.GetServices().SelectMany(x => x.FindResources()) .OfType().Any(x => x.Name == new RabbitMqTransport().Name).ShouldBeTrue(); } + + [Fact] + public void rabbitmq_transport_is_NOT_exposed_as_a_resource_if_external_transports_are_stubbed() + { + var queueName = RabbitTesting.NextQueueName(); + using var publisher = WolverineHost.For(opts => + { + opts.UseRabbitMq().AutoProvision().AutoPurgeOnStartup(); + + opts.PublishAllMessages() + .ToRabbitQueue(queueName) + .UseDurableOutbox(); + + opts.StubAllExternalTransports(); + + opts.Services.AddMarten(x => + { + x.Connection(Servers.PostgresConnectionString); + x.AutoCreateSchemaObjects = AutoCreate.All; + x.DatabaseSchemaName = "sender"; + }).IntegrateWithWolverine(); + + opts.Services.AddResourceSetupOnStartup(StartupAction.ResetState); + }); + + publisher.Services.GetServices().SelectMany(x => x.FindResources()) + .OfType().Any(x => x.Name == new RabbitMqTransport().Name).ShouldBeFalse(); + } + [Fact] diff --git a/src/Wolverine/Runtime/WolverineRuntime.StatefulResources.cs b/src/Wolverine/Runtime/WolverineRuntime.StatefulResources.cs index 9851058b3..4271ce17f 100644 --- a/src/Wolverine/Runtime/WolverineRuntime.StatefulResources.cs +++ b/src/Wolverine/Runtime/WolverineRuntime.StatefulResources.cs @@ -7,6 +7,7 @@ public partial class WolverineRuntime : IStatefulResourceSource IReadOnlyList IStatefulResourceSource.FindResources() { var list = new List(); + if (Options.ExternalTransportsAreStubbed) return list; foreach (var transport in Options.Transports) {