public async Task when_executed_with_message_type_within_context_it_should_find_handlers_for_this_message_and_store_them_in_context() { var container = new Container(); container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle(); container.AddLogging(_testOutput); var handlersRegistry = new VentureServiceHandlersRegistry(new[] { typeof(Message01Handler).Assembly }); var handlers = handlersRegistry.HandlersGroupedByMessageType[typeof(Message01)]; foreach (var handler in handlers) { container.Register(handler); } var sut = new FindMessageHandlersStep(new SimpleInjectorAdapter(container)); var context = new MessageHandlingContext { MessageType = typeof(Message01), Api = new FakeIngressApi { HandlerRegistry = handlersRegistry } }; await sut.Execute(context); var foundHandlers = (IEnumerable <HandlerDescriptor>)context.Handlers; var singleHandler = foundHandlers.Single(); singleHandler.Should().BeOfType <HandlerDescriptor>("should find the handler for the message"); }
public void when_executed_without_context_it_should_throw() { var container = new Container(); container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle(); container.AddLogging(_testOutput); var step = new FindMessageHandlersStep(new SimpleInjectorAdapter(container)); // ReSharper disable once AssignNullToNotNullAttribute - it's a test. Action sut = () => step.Execute(context: null); sut.Should().Throw <ArgumentNullException>("context is required"); }