当前位置: 首页>>代码示例>>C#>>正文


C# Bus.SendAsync方法代码示例

本文整理汇总了C#中Bus.SendAsync方法的典型用法代码示例。如果您正苦于以下问题:C# Bus.SendAsync方法的具体用法?C# Bus.SendAsync怎么用?C# Bus.SendAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bus的用法示例。


在下文中一共展示了Bus.SendAsync方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: When_sending_a_command_and_there_are_no_command_handlers_should_throw_exception

        public void When_sending_a_command_and_there_are_no_command_handlers_should_throw_exception()
        {
            var serviceContainer = new ServiceContainer();
            var bus = new Bus(serviceContainer.GetAllInstances);
            var command = new Command();

            Assert.Throws<NotSupportedException>(() => bus.SendAsync(command).Wait());
        }
开发者ID:kinimatt,项目名称:LightBus,代码行数:8,代码来源:BusTests.cs

示例2: When_sending_a_command_and_there_is_only_one_command_handler_should_invoke_command_handler

        public void When_sending_a_command_and_there_is_only_one_command_handler_should_invoke_command_handler()
        {
            var serviceContainer = new ServiceContainer();
            serviceContainer.Register<IHandleMessages<Command>, CommandHandler>();
            var bus = new Bus(serviceContainer.GetAllInstances);
            var command = new Command();

            bus.SendAsync(command);

            command.IsHandled.ShouldBeTrue();
        }
开发者ID:kinimatt,项目名称:LightBus,代码行数:11,代码来源:BusTests.cs

示例3: When_sending_a_command_should_polymorphic_dispatch_to_command_handlers

        public void When_sending_a_command_should_polymorphic_dispatch_to_command_handlers()
        {
            var serviceContainer = new ServiceContainer();
            serviceContainer.Register<IHandleMessages<Command>, CommandHandler>();
            var messageHandler = new MessageHandler();
            serviceContainer.RegisterInstance<IHandleMessages<IMessage>>(messageHandler);
            var bus = new Bus(serviceContainer.GetAllInstances);
            var command = new Command();

            bus.SendAsync(command);

            command.IsHandled.ShouldBeTrue();
            messageHandler.IsHandled.ShouldBeTrue();
        }
开发者ID:kinimatt,项目名称:LightBus,代码行数:14,代码来源:BusTests.cs

示例4: When_sending_a_command_should_invoke_command_handler_and_be_able_to_wait_for_async_result

        public async Task When_sending_a_command_should_invoke_command_handler_and_be_able_to_wait_for_async_result()
        {
            var serviceContainer = new ServiceContainer();
            var bus = new Bus(serviceContainer.GetAllInstances);
            serviceContainer.Register<IBus>(sf => bus);
            serviceContainer.Register<IHandleMessages<AsyncCommand>, AsyncCommandHandler>();
            var command = new AsyncCommand();

            await bus.SendAsync(command);

            command.IsHandled.ShouldBeTrue();
        }
开发者ID:kinimatt,项目名称:LightBus,代码行数:12,代码来源:BusTests.cs

示例5: When_publishing_an_event_in_a_command_handler_should_handle_event

        public void When_publishing_an_event_in_a_command_handler_should_handle_event()
        {
            var serviceContainer = new ServiceContainer();
            var bus = new Bus(serviceContainer.GetAllInstances);
            serviceContainer.Register<IBus>(sf => bus);
            serviceContainer.Register<IHandleMessages<Command>, CommandHandlerThatSendsAnEvent>();
            serviceContainer.Register<IHandleMessages<EventWithCommand>, EventWithCommandHandler>();
            var command = new Command();

            bus.SendAsync(command);

            command.IsHandled.ShouldBeTrue();
        }
开发者ID:kinimatt,项目名称:LightBus,代码行数:13,代码来源:BusTests.cs

示例6: When_query_handler_throws_exception_should_propagate_exception

        public void When_query_handler_throws_exception_should_propagate_exception()
        {
            var serviceContainer = new ServiceContainer();
            serviceContainer.Register<IHandleQueries<QueryWithExcepetion, Response>, QueryWithExceptionHandler>();
            var bus = new Bus(serviceContainer.GetAllInstances);

            Assert.Throws<InvalidOperationException>(() => bus.SendAsync(new QueryWithExcepetion()).Wait());
        }
开发者ID:kinimatt,项目名称:LightBus,代码行数:8,代码来源:BusTests.cs

示例7: When_command_handler_throws_exception_should_propagate_exception

        public void When_command_handler_throws_exception_should_propagate_exception()
        {
            var serviceContainer = new ServiceContainer();
            serviceContainer.Register<IHandleMessages<CommandWithException>, CommandHandlerThatThrowException>();
            var bus = new Bus(serviceContainer.GetAllInstances);

            Assert.Throws<InvalidOperationException>(() => bus.SendAsync(new CommandWithException()).Wait());
        }
开发者ID:kinimatt,项目名称:LightBus,代码行数:8,代码来源:BusTests.cs

示例8: When_sending_a_query_and_there_are_multiple_query_handlers_should_throw_exception

        public void When_sending_a_query_and_there_are_multiple_query_handlers_should_throw_exception()
        {
            var serviceContainer = new ServiceContainer();
            serviceContainer.Register<IHandleQueries<Query, Response>, QueryHandler>();
            serviceContainer.Register<IHandleQueries<Query, Response>, AnotherQueryHandler>("another");
            var bus = new Bus(serviceContainer.GetAllInstances);
            var query = new Query();

            Assert.Throws<NotSupportedException>(() => bus.SendAsync(query).Wait());
        }
开发者ID:kinimatt,项目名称:LightBus,代码行数:10,代码来源:BusTests.cs

示例9: When_sending_a_query_and_there_is_only_one_query_handler_should_invoke_query_handler

        public void When_sending_a_query_and_there_is_only_one_query_handler_should_invoke_query_handler()
        {
            var serviceContainer = new ServiceContainer();
            serviceContainer.Register<IHandleQueries<Query, Response>, QueryHandler>();
            var bus = new Bus(serviceContainer.GetAllInstances);
            var query = new Query();

            var response = bus.SendAsync(query);

            response.Result.IsHandled.ShouldBeTrue();
        }
开发者ID:kinimatt,项目名称:LightBus,代码行数:11,代码来源:BusTests.cs


注:本文中的Bus.SendAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。