示例#1
0
        public async Task Commands_are_correctly_converted(FakeServer server, ThirdTestCommand testCommand, CommandReceivedAsync <AttributeTestCommand> 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.Is <ICommandContext <AttributeTestCommand> >(c => string.Equals(c.Command.Message, testCommand.Message))), Times.Once);
        }
示例#2
0
        public async Task Commands_are_matched_via_MessageAttribute(ServiceCollection services, ThirdTestCommand testCommand, CommandReceivedAsync <AttributeTestCommand> 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 <AttributeTestCommand> >()), Times.Once);
        }