public async Task Host_can_loopback_commands(ServiceCollection services, SecondTestCommand testCommand, [Frozen] CommandReceivedAsync <SecondTestCommand> commandReceived, SecondTestCommandHandler handler) { services.AddLogging(l => l.AddDebug()); services.AddSingleton(commandReceived); services.AddSingleton(handler); services.AddNybus(nybus => { nybus.UseInMemoryBusEngine(); nybus.SubscribeToCommand <SecondTestCommand, SecondTestCommandHandler>(); }); var serviceProvider = services.BuildServiceProvider(); var host = serviceProvider.GetRequiredService <IBusHost>(); var bus = serviceProvider.GetRequiredService <IBus>(); await host.StartAsync(); await bus.InvokeCommandAsync(testCommand); await host.StopAsync(); Mock.Get(commandReceived).Verify(p => p(It.IsAny <IDispatcher>(), It.IsAny <ICommandContext <SecondTestCommand> >())); }
public async Task Host_can_loopback_commands(FakeServer server, SecondTestCommand testCommand, [Frozen] CommandReceivedAsync <SecondTestCommand> commandReceived, SecondTestCommandHandler handler) { var settings = new Dictionary <string, string> { ["Nybus:ErrorPolicy:ProviderName"] = "retry", ["Nybus:ErrorPolicy:MaxRetries"] = "5", }; var configurationBuilder = new ConfigurationBuilder().AddInMemoryCollection(settings); var configuration = configurationBuilder.Build(); var host = CreateNybusHost(nybus => { nybus.UseRabbitMqBusEngine(rabbitMq => { rabbitMq.Configure(c => c.ConnectionFactory = server.CreateConnectionFactory()); }); nybus.UseConfiguration(configuration); nybus.SubscribeToCommand <SecondTestCommand, SecondTestCommandHandler>(); }, services => { services.AddSingleton(commandReceived); services.AddSingleton(handler); }); await host.StartAsync(); await host.Bus.InvokeCommandAsync(testCommand); await host.StopAsync(); Mock.Get(commandReceived).Verify(p => p(It.IsAny <IDispatcher>(), It.IsAny <ICommandContext <SecondTestCommand> >())); }
public async Task Host_can_loopback_commands(FakeServer server, SecondTestCommand testCommand, [Frozen] CommandReceivedAsync <SecondTestCommand> commandReceived, SecondTestCommandHandler handler) { var host = CreateNybusHost(nybus => { nybus.SubscribeToCommand(commandReceived); nybus.UseRabbitMqBusEngine(rabbitMq => { rabbitMq.Configure(c => c.ConnectionFactory = server.CreateConnectionFactory()); }); nybus.SubscribeToCommand <SecondTestCommand, SecondTestCommandHandler>(); }, services => { services.AddSingleton(commandReceived); services.AddSingleton(handler); }); await host.StartAsync(); await host.Bus.InvokeCommandAsync(testCommand); await host.StopAsync(); Mock.Get(commandReceived).Verify(p => p(It.IsAny <IDispatcher>(), It.IsAny <ICommandContext <SecondTestCommand> >())); }
public async Task Host_can_loopback_commands(ServiceCollection services, SecondTestCommand testCommand, [Frozen] CommandReceivedAsync <SecondTestCommand> commandReceived, SecondTestCommandHandler handler) { var settings = new Dictionary <string, string> { ["Nybus:ErrorPolicy:ProviderName"] = "retry", ["Nybus:ErrorPolicy:MaxRetries"] = "5", }; var configurationBuilder = new ConfigurationBuilder().AddInMemoryCollection(settings); var configuration = configurationBuilder.Build(); services.AddLogging(l => l.AddDebug()); services.AddSingleton(commandReceived); services.AddSingleton(handler); services.AddNybus(nybus => { nybus.UseInMemoryBusEngine(); nybus.UseConfiguration(configuration); nybus.SubscribeToCommand <SecondTestCommand, SecondTestCommandHandler>(); }); var serviceProvider = services.BuildServiceProvider(); var host = serviceProvider.GetRequiredService <IBusHost>(); var bus = serviceProvider.GetRequiredService <IBus>(); await host.StartAsync(); await bus.InvokeCommandAsync(testCommand); await host.StopAsync(); Mock.Get(commandReceived).Verify(p => p(It.IsAny <IDispatcher>(), It.IsAny <ICommandContext <SecondTestCommand> >())); }