diff --git a/src/Nybus.Legacy.NetExtensions.Adapters.MassTransit/NybusLegacyMassTransitServiceCollectionExtensions.cs b/src/Nybus.Legacy.NetExtensions.Adapters.MassTransit/NybusLegacyMassTransitServiceCollectionExtensions.cs index 7742bc5..39ffad1 100644 --- a/src/Nybus.Legacy.NetExtensions.Adapters.MassTransit/NybusLegacyMassTransitServiceCollectionExtensions.cs +++ b/src/Nybus.Legacy.NetExtensions.Adapters.MassTransit/NybusLegacyMassTransitServiceCollectionExtensions.cs @@ -6,7 +6,7 @@ namespace Nybus { public static class NybusLegacyMassTransitServiceCollectionExtensions { - public static IServiceCollection AddNybusWithMassTransit(this IServiceCollection services, NybusLegacyConfiguration configuration) + public static IServiceCollection AddNybusLegacyWithMassTransit(this IServiceCollection services, NybusLegacyConfiguration configuration) { services.AddNybusLegacy(configuration.NybusConfigurator, configuration.SubscriptionsConfigurator); diff --git a/tests/Tests.Nybus.Legacy.NetExtensions.Adapters.MassTransit/NybusLegacyMassTransitServiceCollectionExtensionsTests.cs b/tests/Tests.Nybus.Legacy.NetExtensions.Adapters.MassTransit/NybusLegacyMassTransitServiceCollectionExtensionsTests.cs index 9ee1c7c..3c67e21 100644 --- a/tests/Tests.Nybus.Legacy.NetExtensions.Adapters.MassTransit/NybusLegacyMassTransitServiceCollectionExtensionsTests.cs +++ b/tests/Tests.Nybus.Legacy.NetExtensions.Adapters.MassTransit/NybusLegacyMassTransitServiceCollectionExtensionsTests.cs @@ -10,25 +10,25 @@ namespace Tests public class NybusLegacyMassTransitServiceCollectionExtensionsTests { [Test, AutoMoqData] - public void AddNybusWithMassTransit_registers_MassTransitOptions(IServiceCollection services, NybusLegacyConfiguration configuration) + public void AddNybusLegacyWithMassTransit_registers_MassTransitOptions(IServiceCollection services, NybusLegacyConfiguration configuration) { - services.AddNybusWithMassTransit(configuration); + services.AddNybusLegacyWithMassTransit(configuration); Mock.Get(services).Verify(p => p.Add(It.Is(sd => sd.For()))); } [Test, AutoMoqData] - public void AddNybusWithMassTransit_registers_BusEngine(IServiceCollection services, NybusLegacyConfiguration configuration) + public void AddNybusLegacyWithMassTransit_registers_BusEngine(IServiceCollection services, NybusLegacyConfiguration configuration) { - services.AddNybusWithMassTransit(configuration); + services.AddNybusLegacyWithMassTransit(configuration); Mock.Get(services).Verify(p => p.Add(It.Is(sd => sd.For()))); } [Test, AutoMoqData] - public void AddNybusWithMassTransit_registers_MassTransitConnectionDescriptor(IServiceCollection services, NybusLegacyConfiguration configuration) + public void AddNybusLegacyWithMassTransit_registers_MassTransitConnectionDescriptor(IServiceCollection services, NybusLegacyConfiguration configuration) { - services.AddNybusWithMassTransit(configuration); + services.AddNybusLegacyWithMassTransit(configuration); Mock.Get(services).Verify(p => p.Add(It.Is(sd => sd.For()))); } diff --git a/tests/Tests.Nybus.Legacy.NetExtensions.Adapters.MassTransit/NybusLegacyServiceCollectionExtensionsIntegrationTests.cs b/tests/Tests.Nybus.Legacy.NetExtensions.Adapters.MassTransit/NybusLegacyServiceCollectionExtensionsIntegrationTests.cs index 1c2ef57..3a61506 100644 --- a/tests/Tests.Nybus.Legacy.NetExtensions.Adapters.MassTransit/NybusLegacyServiceCollectionExtensionsIntegrationTests.cs +++ b/tests/Tests.Nybus.Legacy.NetExtensions.Adapters.MassTransit/NybusLegacyServiceCollectionExtensionsIntegrationTests.cs @@ -1,8 +1,10 @@ using AutoFixture.NUnit3; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Moq; using NUnit.Framework; using Nybus; +using Nybus.Configuration; namespace Tests { @@ -16,7 +18,7 @@ public void Bus_can_be_built([Frozen] string connectionStringName, IConfiguratio services.AddLogging(); - services.AddNybusWithMassTransit(nybusConfiguration); + services.AddNybusLegacyWithMassTransit(nybusConfiguration); var serviceProvider = services.BuildServiceProvider(); @@ -24,5 +26,53 @@ public void Bus_can_be_built([Frozen] string connectionStringName, IConfiguratio Assert.That(bus, Is.Not.Null); } + + [Test, AutoMoqData] + public void SubscriptionsConfigurator_is_used_when_building_bus([Frozen] string connectionStringName, IConfiguration configuration, ServiceCollection services, NybusLegacyConfiguration nybusConfiguration) + { + services.AddSingleton(configuration); + + services.AddLogging(); + + services.AddNybusLegacyWithMassTransit(nybusConfiguration); + + var serviceProvider = services.BuildServiceProvider(); + + var bus = serviceProvider.GetRequiredService(); + + Mock.Get(nybusConfiguration.SubscriptionsConfigurator).Verify(p => p(It.IsAny())); + } + + [Test, AutoMoqData] + public void NybusConfigurator_is_used_when_building_bus([Frozen] string connectionStringName, IConfiguration configuration, ServiceCollection services, NybusLegacyConfiguration nybusConfiguration) + { + services.AddSingleton(configuration); + + services.AddLogging(); + + services.AddNybusLegacyWithMassTransit(nybusConfiguration); + + var serviceProvider = services.BuildServiceProvider(); + + var bus = serviceProvider.GetRequiredService(); + + Mock.Get(nybusConfiguration.NybusConfigurator).Verify(p => p(It.IsAny())); + } + + [Test, AutoMoqData] + public void MassTransitConfigurator_is_used_when_building_bus([Frozen] string connectionStringName, IConfiguration configuration, ServiceCollection services, NybusLegacyConfiguration nybusConfiguration) + { + services.AddSingleton(configuration); + + services.AddLogging(); + + services.AddNybusLegacyWithMassTransit(nybusConfiguration); + + var serviceProvider = services.BuildServiceProvider(); + + var bus = serviceProvider.GetRequiredService(); + + Mock.Get(nybusConfiguration.NybusConfigurator).Verify(p => p(It.IsAny())); + } } } \ No newline at end of file