Exemplo n.º 1
0
        public void bus_should_find_handlers_for_a_message_type()
        {
            var bus = new ApplicationBus(new MessageHandlerFactory());

            bus.Add(typeof(fooHandler));
            bus.Add(typeof(barHandler));
            var results = bus.GetHandlersForType(typeof(foo)).ToList();

            results.Count.ShouldEqual(1);
        }
Exemplo n.º 2
0
        public void bus_should_message_to_handlers()
        {
            fooHandler.Sent = false;
            var bus = new ApplicationBus(new MessageHandlerFactory());

            bus.Add(typeof(fooHandler));
            bus.Add(typeof(barHandler));
            bus.Send(new foo());
            fooHandler.Sent.ShouldBeTrue();
        }
Exemplo n.º 3
0
        public void bus_should_only_add_message_handlers()
        {
            var bus = new ApplicationBus(new MessageHandlerFactory());

            try
            {
                bus.Add(this.GetType());
            }
            catch (InvalidOperationException ex)
            {
                ex.Message.EndsWith("must implement the IMessageHandler interface").ShouldBeTrue();
                return;
            }
            Assert.Fail("Add should throw exception when adding invalid message handler types");
        }
 private static void RegisterThisApplicationBusInstanceWithTheServiceLocator(IRotorContext context, ApplicationBus applicationBus)
 {
     var serviceLocator = context.ServiceLocator;
     serviceLocator.Register<IApplicationBus>(applicationBus);
 }