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_created_it_should_provide_handler_types_grouped_by_handled_message_type() { var sut = new VentureServiceHandlersRegistry(new[] { typeof(Message01Handler).Assembly }); sut.HandlersGroupedByMessageType.ContainsKey(typeof(Message01)).Should() .BeTrue($"there is at least one handler for {nameof(Message01)} event"); }
private static void AddIngressPipeline(Container container) { // TODO: I need to test this pipeline itself because for the moment it fails. container.RegisterSingleton <VentureIngressPipeFitter>(); container.RegisterSingleton <EmptyEgressApiMessageTypesRegistry>(); container.Register <IHandlersExecutionStrategy, ParallelHandlersExecutionStrategy>(); container.RegisterSingleton <IAggregateStorage <ResearchCase>, AlmostRealAggregateStorage <ResearchCase> >(); container.RegisterSingleton <IAggregateStorage <JusticeCase>, AlmostRealAggregateStorage <JusticeCase> >(); container.Register <ExtractRelationMetadataStep>(Lifestyle.Scoped); container.Register <ExtractMessageTypeStep>(Lifestyle.Scoped); container.Register <ParseBrokerMessageStep>(Lifestyle.Scoped); container.Register <FindMessageHandlersStep>(Lifestyle.Scoped); container.Register <ExecuteMessageHandlersStep>(Lifestyle.Scoped); var handlersRegistry = new VentureServiceHandlersRegistry(new[] { typeof(AssemblyTag).Assembly }); container.RegisterInstance(handlersRegistry); var handlers = handlersRegistry.HandlersGroupedByMessageType[typeof(CreateJusticeCase)]; foreach (var handler in handlers) { container.Register(handler); } }