Example #1
0
        public void build_services_for_a_service_registry()
        {
            var graph = FubuTransportRegistry.BehaviorGraphFor(x => x.Services <FooServiceRegistry>());

            graph.Services.ServicesFor <IFoo>().Select(x => x.Type)
            .ShouldHaveTheSameElementsAs(typeof(GreenFoo), typeof(RedFoo));
        }
Example #2
0
        public void handler_calls_are_registered_by_default()
        {
            var graph = FubuTransportRegistry.HandlerGraphFor(x => { });

            graph.ChainFor <TakeOwnershipRequest>().ShouldNotBeNull();
            graph.ChainFor <TaskHealthRequest>().ShouldNotBeNull();
            graph.ChainFor <TaskDeactivation>().ShouldNotBeNull();
        }
Example #3
0
        public void is_registered_if_FubuTransport_in_memory_testing()
        {
            FubuTransport.AllQueuesInMemory = true;

            var graph = FubuTransportRegistry.BehaviorGraphFor(x => { });

            graph.Services.ServicesFor <ITransport>()
            .Any(x => x.Type == typeof(InMemoryTransport))
            .ShouldBeTrue();
        }
Example #4
0
        public void is_not_registered_normally()
        {
            FubuTransport.Reset();

            var graph = FubuTransportRegistry.BehaviorGraphFor(x => { });

            graph.Services.ServicesFor <ITransport>()
            .Any(x => x.Type == typeof(InMemoryTransport))
            .ShouldBeFalse();
        }
        public void async_handling_node_should_be_right_before_any_calls()
        {
            var graph = FubuTransportRegistry.HandlerGraphFor(x => { });

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

            graph.ChainFor(typeof(Message3)).OfType <HandlerCall>()
            .First().Previous.ShouldBeOfType <AsyncHandlingNode>();
        }
        public void should_have_an_error_behavior_on_each_chain()
        {
            var graph = FubuTransportRegistry.HandlerGraphFor(x => { });

            foreach (HandlerChain chain in graph)
            {
                chain.First().ShouldBeOfType <ExceptionHandlerNode>()
                .Chain.ShouldBeTheSameAs(chain);
            }
        }
Example #7
0
        public void import_an_extension()
        {
            var graph = FubuTransportRegistry.HandlerGraphFor(x => {
                x.Import <DoerExtension>();
            });

            graph.ChainFor(typeof(Message1)).OfType <HandlerCall>()
            .Any(x => x.HandlerType == typeof(OneDoer))
            .ShouldBeTrue();
        }
        public void default_handler_sources_are_not_used_if_a_custom_one_is_registered_and_disabled()
        {
            var graph = FubuTransportRegistry.HandlerGraphFor(r => {
                r.Handlers.DisableDefaultHandlerSource();
                r.Handlers.FindBy <MyFunkyHandlerSource>();
            });

            graph.ChainFor(typeof(Message1)).OfType <HandlerCall>().Select(x => x.HandlerType)
            .Single().ShouldEqual(typeof(MyFunkySpaceAgeProcessor));
        }
Example #9
0
        public void build_services_inline()
        {
            var graph = FubuTransportRegistry.BehaviorGraphFor(x => {
                x.Services(s => {
                    s.AddService <IFoo, BlueFoo>();
                    s.AddService <IFoo, RedFoo>();
                });
            });

            graph.Services.ServicesFor <IFoo>().Select(x => x.Type)
            .ShouldHaveTheSameElementsAs(typeof(BlueFoo), typeof(RedFoo));
        }
Example #10
0
        public void is_registered_if_user_opted_into_in_memory_transport()
        {
            FubuTransport.Reset();

            var graph = FubuTransportRegistry.BehaviorGraphFor(x => {
                x.AlterSettings <TransportSettings>(o => o.EnableInMemoryTransport = true);
            });

            graph.Services.ServicesFor <ITransport>()
            .Any(x => x.Type == typeof(InMemoryTransport))
            .ShouldBeTrue();
        }
        public void use_the_special_storage_just_fine()
        {
            var graph = FubuTransportRegistry.HandlerGraphFor(x => {
                x.SagaStorage <SpecialSagaStorage>();
            });

            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.Type.ShouldEqual(typeof(SpecialSagaRepository <MySagaState, SagaMessageOne>));
        }
        public void can_register_a_handler_source_by_explicit_config()
        {
            var graph = FubuTransportRegistry.HandlerGraphFor(x => {
                x.Handlers.DisableDefaultHandlerSource();
                x.Handlers.FindBy(source => {
                    source.UseThisAssembly();
                    source.IncludeTypesNamed(name => name.Contains("FooHandler"));
                });
            });

            graph.SelectMany(x => x.OfType <HandlerCall>()).Where(x => x.HandlerType.Assembly != typeof(HandlerCall).Assembly).Select(x => x.HandlerType).OrderBy(x => x.Name)
            .ShouldHaveTheSameElementsAs(typeof(MyFooHandler), typeof(MyOtherFooHandler));
        }
        public void extra_handler_sources_are_additive()
        {
            var graph = FubuTransportRegistry.HandlerGraphFor(x =>
            {
                x.Handlers.Include <RandomThing>();
            });

            var handlerTypes = graph.SelectMany(x => x.OfType <HandlerCall>()).Select(x => x.HandlerType).ToArray();

            handlerTypes.ShouldContain(typeof(MyOtherConsumer));
            handlerTypes.ShouldContain(typeof(MyFooHandler));
            handlerTypes.ShouldContain(typeof(RandomThing));
        }
        protected override void beforeEach()
        {
            theGraph = FubuTransportRegistry.HandlerGraphFor(x =>
            {
                x.Handlers.DisableDefaultHandlerSource();
                x.Handlers.Include <OneHandler>();
                x.Handlers.Include <TwoHandler>();
                x.Handlers.Include <ThreeHandler>();
                x.Handlers.Include <FourHandler>();
            });

            Services.Inject <HandlerGraph>(theGraph);
        }
        public void the_saga_node_is_before_the_handler_calls()
        {
            var graph = FubuTransportRegistry.HandlerGraphFor(x => {
                x.SagaStorage <SpecialSagaStorage>();
            });

            var chain    = graph.ChainFor(typeof(SagaMessageOne));
            var sagaNode = chain.OfType <StatefulSagaNode>()
                           .FirstOrDefault();

            sagaNode.PreviousNodes.Any(x => x is HandlerCall).ShouldBeFalse();
            sagaNode.Any(x => x is HandlerCall).ShouldBeTrue();
        }
        IEnumerable <HandlerCall> IHandlerSource.FindCalls()
        {
            var types = new TypePool();

            if (_assemblies.Any())
            {
                types.AddAssemblies(_assemblies);
            }
            else
            {
                types.AddAssembly(FubuTransportRegistry.FindTheCallingAssembly());
            }

            return(types.TypesMatching(_typeFilters.Matches).SelectMany(actionsFromType));
        }
Example #17
0
        public void can_find_chain_for_input_type()
        {
            var graph = FubuTransportRegistry.HandlerGraphFor(x => {
                x.Handlers.Include <OneHandler>();
                x.Handlers.Include <TwoHandler>();

                x.Handlers.DisableDefaultHandlerSource();
            });

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

            invoker.FindChain(new Envelope {
                Message = new OneMessage()
            })
            .OfType <HandlerCall>().Single()
            .HandlerType.ShouldEqual(typeof(OneHandler));
        }
        public void can_override_the_default_handler_source_by_explicits_and_disabled()
        {
            var graph = FubuTransportRegistry.HandlerGraphFor(r =>
            {
                r.Handlers.FindBy(x => {
                    x.IncludeClassesSuffixedWithConsumer();
                });

                r.Handlers.DisableDefaultHandlerSource();
            });

            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 SetUp()
        {
            theTransportRegistry = FubuTransportRegistry.Empty();
            theTransportRegistry.Handlers.DisableDefaultHandlerSource();
            theTransportRegistry.EnableInMemoryTransport();

            TestMessageRecorder.Clear();

            _invoker = new Lazy <IChainInvoker>(() => {
                var container = new Container();
                theRuntime    = FubuTransport.For(theTransportRegistry).StructureMap(container).Bootstrap();

                return(container.GetInstance <IChainInvoker>());
            });

            theCallback = MockRepository.GenerateMock <IMessageCallback>();

            theContextIs();
        }
 public FubuTransportRegistryProvenance(FubuTransportRegistry registry)
 {
     _registry = registry;
 }
 public void Configure(FubuTransportRegistry registry)
 {
     registry.Handlers.FindBy(x => {
         x.IncludeClassesSuffixedWith("Doer");
     });
 }
Example #22
0
 public void Configure(FubuTransportRegistry registry)
 {
     registry.Handlers.FindBy(x => {
         x.IncludeClassesSuffixedWith("Doer");
     });
 }
 public ScheduledJobExpression(FubuTransportRegistry parent, ScheduledJobHandlerSource scheduledJobs)
 {
     _parent        = parent;
     _scheduledJobs = scheduledJobs;
 }
 public void should_automatically_pick_up_classes_suffixed_with_Consumer()
 {
     FubuTransportRegistry.HandlerGraphFor(r => { })
     .ChainFor(typeof(Message1)).OfType <HandlerCall>().Any(x => x.HandlerType == typeof(MyNewConsumer))
     .ShouldBeTrue();
 }
 public void find_the_calling_assembly()
 {
     FubuTransportRegistry.FindTheCallingAssembly()
     .ShouldEqual(Assembly.GetExecutingAssembly());
 }
Example #26
0
 public ScheduledExecutionExpression(FubuTransportRegistry registry)
 {
     _registry = registry;
 }
Example #27
0
 public PollingJobExpression(FubuTransportRegistry parent)
 {
     _parent = parent;
 }
 public void AddGlobal(IConfigurationAction action, FubuTransportRegistry registry)
 {
     _globalPolicies.Fill(new Provenance[]{new FubuTransportRegistryProvenance(registry) }, action);
 }
Example #29
0
 public HealthMonitoringExpression(FubuTransportRegistry parent)
 {
     _parent = parent;
 }
Example #30
0
 public void AddGlobal(IConfigurationAction action, FubuTransportRegistry registry)
 {
     _globalPolicies.Fill(action);
 }
 public void UseThisAssembly()
 {
     UseAssembly(FubuTransportRegistry.FindTheCallingAssembly());
 }