예제 #1
0
        public void service_registrations()
        {
            using (var runtime = FubuRuntime.BasicBus())
            {
                var c = runtime.Get <IContainer>();


                c.DefaultSingletonIs <ISubscriptionCache, SubscriptionCache>();
                c.DefaultSingletonIs <ISagaStateCacheFactory, SagaStateCacheFactory>();
                c.DefaultSingletonIs <IEventAggregator, EventAggregator>();

                c.DefaultRegistrationIs <IServiceBus, Core.ServiceBus.ServiceBus>();
                c.DefaultRegistrationIs <IEnvelopeSender, EnvelopeSender>();
                c.DefaultRegistrationIs <IEnvelopeSerializer, EnvelopeSerializer>();
                c.DefaultRegistrationIs <IChainInvoker, ChainInvoker>();
                c.DefaultRegistrationIs <IMessageSerializer, XmlMessageSerializer>();
                c.DefaultRegistrationIs <IHandlerPipeline, HandlerPipeline>();
                c.DefaultRegistrationIs <IMessageExecutor, MessageExecutor>();
                c.DefaultRegistrationIs <IOutgoingSender, OutgoingSender>();
                c.DefaultRegistrationIs <ISubscriptionRepository, SubscriptionRepository>();


                c.ShouldHaveRegistration <IActivator, ServiceBusActivator>();
                c.ShouldHaveRegistration <ILogListener, EventAggregationListener>();

                c.ShouldNotHaveRegistration <IActivator, TransportCleanupActivator>();
            }
        }
        public void SetUp()
        {
            runtime = FubuRuntime.BasicBus();
            runtime.Get <IContainer>().UseInMemoryDatastore();

            persistence = runtime.Get <RavenDbSubscriptionPersistence>();
        }
        public void SetUp()
        {
            runtime = FubuRuntime.BasicBus();
            runtime.Get <IContainer>().UseInMemoryDatastore();

            thePersistence = runtime.Get <RavenDbSchedulePersistence>();

            foo1 = new JobStatusDTO {
                JobKey = "1", NodeName = "foo"
            };
            foo2 = new JobStatusDTO {
                JobKey = "2", NodeName = "foo"
            };
            foo3 = new JobStatusDTO {
                JobKey = "3", NodeName = "foo"
            };
            bar1 = new JobStatusDTO {
                JobKey = "1", NodeName = "bar"
            };
            bar2 = new JobStatusDTO {
                JobKey = "2", NodeName = "bar"
            };

            thePersistence.Persist(new[] { foo1, foo2, foo3, bar1, bar2 });
        }
예제 #4
0
        public void can_register_a_handler_source_by_explicit_config()
        {
            using (var runtime = FubuRuntime.BasicBus(x =>
            {
                x.Handlers.DisableDefaultHandlerSource();
                x.Handlers.FindBy(source =>
                {
                    source.UseThisAssembly();
                    source.IncludeTypesNamed(name => name.Contains("FooHandler"));
                });
            }))
            {
                var graph = runtime.Behaviors;


                var handlers =
                    graph.Chains.SelectMany(x => x.OfType <HandlerCall>())
                    .Where(x => x.HandlerType.Assembly != typeof(HandlerCall).Assembly)
                    .Select(x => x.HandlerType)
                    .ToArray();


                handlers.ShouldContain(typeof(MyFooHandler));
                handlers.ShouldContain(typeof(MyOtherFooHandler));
            }
        }
 public void the_job_is_registered()
 {
     using (var runtime = FubuRuntime.BasicBus())
     {
         runtime.Get <IPollingJobs>().Any(x => x is PollingJob <HealthMonitorPollingJob, HealthMonitoringSettings>)
         .ShouldBeTrue();
     }
 }
예제 #6
0
 public void should_automatically_pick_up_classes_suffixed_with_Consumer()
 {
     using (var runtime = FubuRuntime.BasicBus())
     {
         runtime.Behaviors.ChainFor(typeof(Message1)).OfType <HandlerCall>().Any(x => x.HandlerType == typeof(MyNewConsumer))
         .ShouldBeTrue();
     }
 }
 public void SubscriptionHandler_should_be_part_of_the_application()
 {
     using (var runtime = FubuRuntime.BasicBus())
     {
         var graph = runtime.Get <BehaviorGraph>();
         graph.ChainFor(typeof(SubscriptionRequested)).ShouldNotBeNull();
         graph.ChainFor(typeof(SubscriptionsChanged)).ShouldNotBeNull();
     }
 }
예제 #8
0
        public void use_synchronous_event_aggregator_if_in_testing_mode()
        {
            using (var runtime = FubuRuntime.BasicBus(x => x.Mode = "testing"))
            {
                var c = runtime.Get <IContainer>();

                c.DefaultSingletonIs <IEventAggregator, SynchronousEventAggregator>();
            }
        }
예제 #9
0
 public void handler_calls_are_registered_by_default()
 {
     using (var runtime = FubuRuntime.BasicBus())
     {
         runtime.Behaviors.ChainFor <TakeOwnershipRequest>().ShouldNotBeNull();
         runtime.Behaviors.ChainFor <TaskHealthRequest>().ShouldNotBeNull();
         runtime.Behaviors.ChainFor <TaskDeactivation>().ShouldNotBeNull();
     }
 }
예제 #10
0
        public void service_registrations_when_not_in_testing_mode()
        {
            using (var runtime = FubuRuntime.BasicBus())
            {
                var c = runtime.Get <IContainer>();

                c.Model.HasImplementationsFor <IMessagingSession>().ShouldBeFalse();
                c.ShouldNotHaveRegistration <ILogListener, MessageRecordListener>();
            }
        }
예제 #11
0
 public void the_cleanup_job_is_registered()
 {
     using (var runtime = FubuRuntime.BasicBus()
            )
     {
         runtime.Get <IPollingJobs>()
         .Any(x => x is PollingJob <ExpiringListenerCleanup, TransportSettings>)
         .ShouldBeTrue();
     }
 }
예제 #12
0
        public void service_registrations_when_mode_is_testing()
        {
            using (var runtime = FubuRuntime.BasicBus(x => x.Mode = "testing"))
            {
                var c = runtime.Get <IContainer>();

                c.DefaultRegistrationIs <IMessagingSession, MessagingSession>();
                c.ShouldHaveRegistration <ILogListener, MessageRecordListener>();
            }
        }
        public void registrations()
        {
            using (var runtime = FubuRuntime.BasicBus())
            {
                var container = runtime.Get <IContainer>();

                container.ShouldHaveRegistration <ILogModifier, PersistentTaskMessageModifier>();

                container.DefaultRegistrationIs <IPersistentTaskController, PersistentTaskController>();
                container.DefaultRegistrationIs <ITaskMonitoringSource, TaskMonitoringSource>();
            }
        }
예제 #14
0
 public void default_handler_sources_are_not_used_if_a_custom_one_is_registered_2_and_disabled()
 {
     using (var runtime = FubuRuntime.BasicBus(r =>
     {
         r.Handlers.FindBy(new MyFunkyHandlerSource());
         r.Handlers.DisableDefaultHandlerSource();
     }))
     {
         runtime.Behaviors.ChainFor(typeof(Message1)).OfType <HandlerCall>().Select(x => x.HandlerType)
         .Single().ShouldBe(typeof(MyFunkySpaceAgeProcessor));
     }
 }
예제 #15
0
        public void extra_handler_sources_are_additive()
        {
            using (var runtime = FubuRuntime.BasicBus(x => { x.Handlers.Include <RandomThing>(); }))
            {
                var graph = runtime.Behaviors;

                var handlerTypes =
                    graph.Chains.SelectMany(x => x.OfType <HandlerCall>()).Select(x => x.HandlerType).ToArray();
                handlerTypes.ShouldContain(typeof(MyOtherConsumer));
                handlerTypes.ShouldContain(typeof(MyFooHandler));
                handlerTypes.ShouldContain(typeof(RandomThing));
            }
        }
예제 #16
0
        public void async_handling_node_should_be_right_before_any_calls()
        {
            using (var runtime = FubuRuntime.BasicBus())
            {
                var graph = runtime.Behaviors;

                graph.ChainFor(typeof(Message)).OfType <HandlerCall>()
                .First().Previous.ShouldBeOfType <AsyncHandlingNode>();

                graph.ChainFor(typeof(Message3)).OfType <HandlerCall>()
                .First().Previous.ShouldBeOfType <AsyncHandlingNode>();
            }
        }
예제 #17
0
        public void service_registrations()
        {
            using (var runtime = FubuRuntime.BasicBus())
            {
                var container = runtime.Get <IContainer>();

                container.DefaultRegistrationIs <ITimer, DefaultTimer>();
                container.DefaultRegistrationIs <IPollingJobLogger, PollingJobLogger>();

                container.ShouldHaveRegistration <IDeactivator, PollingJobDeactivator>();

                container.DefaultSingletonIs <IPollingJobs, PollingJobs>();
            }
        }
예제 #18
0
        public void can_override_the_default_handler_source_by_explicits_and_disabled()
        {
            using (var runtime = FubuRuntime.BasicBus(r =>
            {
                r.Handlers.FindBy(x => x.IncludeClassesSuffixedWithConsumer());

                r.Handlers.DisableDefaultHandlerSource();
            }))
            {
                var graph = runtime.Behaviors;
                graph.ChainFor(typeof(Message1)).OfType <HandlerCall>().Any(x => x.HandlerType == typeof(MyNewConsumer))
                .ShouldBeTrue();

                graph.ChainFor(typeof(Message1)).OfType <HandlerCall>().Any(x => x.HandlerType == typeof(MyNewHandler))
                .ShouldBeFalse();
            }
        }
        public void must_be_a_singleton()
        {
            using (var runtime = FubuRuntime.BasicBus()
                   )
            {
                var container = runtime.Get <IContainer>();

                var graph1 = container.GetInstance <ChannelGraph>();
                var graph2 = container.GetInstance <ChannelGraph>();
                var graph3 = container.GetInstance <ChannelGraph>();
                var graph4 = container.GetInstance <ChannelGraph>();

                graph1.ShouldBeTheSameAs(graph2);
                graph1.ShouldBeTheSameAs(graph3);
                graph1.ShouldBeTheSameAs(graph4);
            }
        }
        public void use_the_special_storage_just_fine()
        {
            using (var runtime = FubuRuntime.BasicBus(x => x.ServiceBus.SagaStorage<SpecialSagaStorage>()))
            {
                var graph = runtime.Behaviors;
                var chain = graph.ChainFor(typeof(SagaMessageOne));
                chain.OfType<StatefulSagaNode>()
                    .FirstOrDefault()  // there are two saga's using this message, just worry about the first one
                    .Repository.ReturnedType.ShouldBe(typeof(SpecialSagaRepository<MySagaState, SagaMessageOne>));

                // The saga node should be before the handler calls
                var sagaNode = chain.OfType<StatefulSagaNode>()
                    .FirstOrDefault();

                sagaNode.PreviousNodes.Any(x => x is HandlerCall).ShouldBeFalse();
                sagaNode.Any(x => x is HandlerCall).ShouldBeTrue();
            }

        }
 public void should_have_an_error_behavior_on_each_chain()
 {
     using (var runtime = FubuRuntime.BasicBus())
     {
         foreach (HandlerChain chain in runtime.Behaviors.Handlers)
         {
             if (chain.First() is AsyncHandlingNode)
             {
                 chain.First().Next.ShouldBeOfType <ExceptionHandlerNode>()
                 .Chain.ShouldBeTheSameAs(chain);
             }
             else
             {
                 chain.First().ShouldBeOfType <ExceptionHandlerNode>()
                 .Chain.ShouldBeTheSameAs(chain);
             }
         }
     }
 }
        public void should_move_message_to_error_queue()
        {
            using (var runtime = FubuRuntime.BasicBus(x =>
            {
                x.Handlers.DisableDefaultHandlerSource();
                x.Handlers.Include <OneHandler>();
                x.Handlers.Include <TwoHandler>();
                x.Handlers.Include <ThreeHandler>();
                x.Handlers.Include <FourHandler>();
            }))
            {
                Services.Inject(runtime.Behaviors);

                var envelope = ObjectMother.Envelope();
                envelope.Message = new Message1();
                ClassUnderTest.Invoke(envelope, new TestEnvelopeContext()); // we don't have a handler for this type

                envelope.Callback.AssertWasCalled(x => x.MoveToErrors(
                                                      new ErrorReport(envelope, new NoHandlerException(typeof(Message1)))));
            }
        }
예제 #23
0
        public void can_find_chain_for_input_type()
        {
            using (var runtime = FubuRuntime.BasicBus(x =>
            {
                x.Handlers.Include <OneHandler>();
                x.Handlers.Include <TwoHandler>();

                x.Handlers.DisableDefaultHandlerSource();
            }))
            {
                var graph = runtime.Behaviors;


                var invoker = new ChainInvoker(null, new ChainResolutionCache(graph), null, null, null);

                invoker.FindChain(new Envelope {
                    Message = new OneMessage()
                })
                .OfType <HandlerCall>().Single()
                .HandlerType.ShouldBe(typeof(OneHandler));
            }
        }
        public void should_move_message_to_error_queue()
        {
            using (var runtime = FubuRuntime.BasicBus(x =>
            {
                x.Handlers.DisableDefaultHandlerSource();
                x.Handlers.Include <OneHandler>();
                x.Handlers.Include <TwoHandler>();
                x.Handlers.Include <ThreeHandler>();
                x.Handlers.Include <FourHandler>();
            }))
            {
                Services.Inject(runtime.Behaviors);

                MockFor <IEnvelopeHandler>().Stub(x => x.Handle(null)).IgnoreArguments().Return(Task.FromResult <IContinuation>(null));

                var envelope = ObjectMother.Envelope();
                envelope.Message = new Message1();
                ClassUnderTest.Invoke(envelope, new TestEnvelopeContext()).GetAwaiter().GetResult(); // we don't have a handler for this type

                envelope.Callback.AssertWasCalled(x => x.MoveToErrors(
                                                      new ErrorReport(envelope, new NoHandlerException(typeof(Message1)))));
            }
        }