Ejemplo n.º 1
0
        public async Task Outgoing_commands_are_marked_via_MessageAttribute(FakeServer server, AttributeTestCommand testCommand, CommandReceivedAsync <ThirdTestCommand> commandReceived)
        {
            var host = CreateNybusHost(nybus =>
            {
                nybus.SubscribeToCommand(commandReceived);

                nybus.UseRabbitMqBusEngine(rabbitMq =>
                {
                    rabbitMq.Configure(c => c.ConnectionFactory = server.CreateConnectionFactory());
                });
            });

            await host.StartAsync();

            await host.Bus.InvokeCommandAsync(testCommand);

            await host.StopAsync();

            Mock.Get(commandReceived).Verify(p => p(It.IsAny <IDispatcher>(), It.IsAny <ICommandContext <ThirdTestCommand> >()), Times.Once);
        }
Ejemplo n.º 2
0
        public async Task Outgoing_commands_are_marked_via_MessageAttribute(ServiceCollection services, AttributeTestCommand testCommand, CommandReceivedAsync <ThirdTestCommand> commandReceived)
        {
            services.AddLogging(l => l.AddDebug());

            services.AddNybus(nybus =>
            {
                nybus.UseInMemoryBusEngine();

                nybus.SubscribeToCommand(commandReceived);
            });

            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 <ThirdTestCommand> >()), Times.Once);
        }