Skip to content

Commit

Permalink
Renamed AddNybusWithMassTransit to AddNybusLegacyWithMassTransit
Browse files Browse the repository at this point in the history
  • Loading branch information
Kralizek committed May 14, 2019
1 parent 8528a23 commit 5f2b246
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ServiceDescriptor>(sd => sd.For<MassTransitOptions>())));
}

[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<ServiceDescriptor>(sd => sd.For<IBusEngine>())));
}

[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<ServiceDescriptor>(sd => sd.For<MassTransitConnectionDescriptor>())));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -16,13 +18,61 @@ public void Bus_can_be_built([Frozen] string connectionStringName, IConfiguratio

services.AddLogging();

services.AddNybusWithMassTransit(nybusConfiguration);
services.AddNybusLegacyWithMassTransit(nybusConfiguration);

var serviceProvider = services.BuildServiceProvider();

var bus = serviceProvider.GetRequiredService<IBus>();

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<IBus>();

Mock.Get(nybusConfiguration.SubscriptionsConfigurator).Verify(p => p(It.IsAny<IBusBuilder>()));
}

[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<IBus>();

Mock.Get(nybusConfiguration.NybusConfigurator).Verify(p => p(It.IsAny<NybusOptions>()));
}

[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<IBus>();

Mock.Get(nybusConfiguration.NybusConfigurator).Verify(p => p(It.IsAny<NybusOptions>()));
}
}
}

0 comments on commit 5f2b246

Please sign in to comment.