本文整理汇总了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());
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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());
}
示例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());
}
示例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());
}
示例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();
}