public void SetUp()
        {
            TestMessageRecorder.Clear();
            FubuTransport.Reset();

            // Need to do something about this.  Little ridiculous
            var settings = new BusSettings
            {
                Downstream = "lq.tcp://localhost:2040/downstream".ToUri()
            };
            var lightningUri = settings.Downstream.ToLightningUri();

            var container = new Container();

            container.Inject(settings);



            _runtime = FubuTransport.For <ErrorRegistry>().StructureMap(container)
                       .Bootstrap();
            //_runtime.Factory.Get<IPersistentQueues>().ClearAll();

            theServiceBus = _runtime.Factory.Get <IServiceBus>();

            _queueManager = _runtime.Factory.Get <IPersistentQueues>().ManagerFor(lightningUri.Port, true);

            message1 = new OneMessage();

            theServiceBus.Send(message1);
        }
        public void SetUp()
        {
            FubuTransport.Reset();

            // Need to do something about this.  Little ridiculous
            var settings = new BusSettings
            {
                Downstream = "lq.tcp://localhost:2020/downstream".ToUri()
            };

            var container = new Container();
            container.Inject(settings);

            _runtime = FubuTransport.For<DelayedRegistry>().StructureMap(container)
                                       .Bootstrap();

            theServiceBus = _runtime.Factory.Get<IServiceBus>();
            _runtime.Factory.Get<IPersistentQueues>().ClearAll();

            theClock = _runtime.Factory.Get<ISystemTime>().As<SettableClock>();

            message1 = new OneMessage();
            message2 = new OneMessage();
            message3 = new OneMessage();
            message4 = new OneMessage();

            theServiceBus.DelaySend(message1, theClock.UtcNow().AddHours(1));
            theServiceBus.DelaySend(message2, theClock.UtcNow().AddHours(1));
            theServiceBus.DelaySend(message3, theClock.UtcNow().AddHours(2));
            theServiceBus.DelaySend(message4, theClock.UtcNow().AddHours(2));
        }
        public void SetUp()
        {
            // Need to do something about this.  Little ridiculous
            FubuTransport.SetupForInMemoryTesting();
            TestMessageRecorder.Clear();
            MessageHistory.ClearAll();
            InMemoryQueueManager.ClearAll();

            runtime = FubuTransport.For<DelayedRegistry>().StructureMap(new Container())
                                       .Bootstrap();

            theServiceBus = runtime.Factory.Get<IServiceBus>();

            theClock = runtime.Factory.Get<ISystemTime>().As<SettableClock>();

            message1 = new OneMessage();
            message2 = new OneMessage();
            message3 = new OneMessage();
            message4 = new OneMessage();

            theServiceBus.DelaySend(message1, theClock.UtcNow().AddHours(1));
            theServiceBus.DelaySend(message2, theClock.UtcNow().AddHours(1));
            theServiceBus.DelaySend(message3, theClock.UtcNow().AddHours(2));
            theServiceBus.DelaySend(message4, theClock.UtcNow().AddHours(2));
        }
Exemple #4
0
        public void SetUp()
        {
            TestMessageRecorder.Clear();

            // Need to do something about this.  Little ridiculous
            var settings = new BusSettings
            {
                Downstream = "lq.tcp://localhost:2040/downstream".ToUri()
            };
            var lightningUri = settings.Downstream.ToLightningUri();


            _runtime = FubuRuntime.For <ErrorRegistry>(x =>
            {
                x.Services.For <BusSettings>().Use(settings);
            });


            _runtime.Get <IPersistentQueues>().ClearAll();

            theServiceBus = _runtime.Get <IServiceBus>();

            _queueManager = _runtime.Get <IPersistentQueues>().PersistentManagerFor(lightningUri.Port, true);

            message1 = new OneMessage();

            theServiceBus.Send(message1);
        }
        public void SetUp()
        {
            // Need to do something about this.  Little ridiculous
            var settings = new BusSettings
            {
                Downstream = "lq.tcp://localhost:2050/downstream".ToUri()
            };


            theClock = new SettableClock();


            _runtime = FubuRuntime.For <DelayedRegistry>(_ =>
            {
                _.Services.ReplaceService(settings);
                _.Services.ReplaceService <ISystemTime>(theClock);
            });

            theServiceBus = _runtime.Get <IServiceBus>();
            //_runtime.Get<IPersistentQueues>().ClearAll();

            message1 = new OneMessage();
            message2 = new OneMessage();
            message3 = new OneMessage();
            message4 = new OneMessage();

            Debug.WriteLine("The current Utc time is " + theClock.UtcNow());

            theServiceBus.DelaySend(message1, theClock.UtcNow().AddHours(1));
            theServiceBus.DelaySend(message2, theClock.UtcNow().AddHours(1));
            theServiceBus.DelaySend(message3, theClock.UtcNow().AddHours(2));
            theServiceBus.DelaySend(message4, theClock.UtcNow().AddHours(2));
        }
Exemple #6
0
        public void SetUp()
        {
            FubuTransport.Reset();

            // Need to do something about this.  Little ridiculous
            var settings = new BusSettings
            {
                Downstream = "lq.tcp://localhost:2050/downstream".ToUri()
            };


            var container = new Container();

            container.Inject(settings);
            theClock = new SettableClock();
            container.Inject <ISystemTime>(theClock);

            _runtime = FubuTransport.For <DelayedRegistry>().StructureMap(container)
                       .Bootstrap();

            theServiceBus = _runtime.Factory.Get <IServiceBus>();
            //_runtime.Factory.Get<IPersistentQueues>().ClearAll();

            message1 = new OneMessage();
            message2 = new OneMessage();
            message3 = new OneMessage();
            message4 = new OneMessage();

            Debug.WriteLine("The current Utc time is " + theClock.UtcNow());

            theServiceBus.DelaySend(message1, theClock.UtcNow().AddHours(1));
            theServiceBus.DelaySend(message2, theClock.UtcNow().AddHours(1));
            theServiceBus.DelaySend(message3, theClock.UtcNow().AddHours(2));
            theServiceBus.DelaySend(message4, theClock.UtcNow().AddHours(2));
        }
Exemple #7
0
        public void SetUp()
        {
            // Need to do something about this.  Little ridiculous
            FubuTransport.SetupForInMemoryTesting();
            TestMessageRecorder.Clear();
            MessageHistory.ClearAll();
            InMemoryQueueManager.ClearAll();

            runtime = FubuTransport.For <DelayedRegistry>().StructureMap(new Container())
                      .Bootstrap();

            theServiceBus = runtime.Factory.Get <IServiceBus>();

            theClock = runtime.Factory.Get <ISystemTime>().As <SettableClock>();

            message1 = new OneMessage();
            message2 = new OneMessage();
            message3 = new OneMessage();
            message4 = new OneMessage();

            theServiceBus.DelaySend(message1, theClock.UtcNow().AddHours(1));
            theServiceBus.DelaySend(message2, theClock.UtcNow().AddHours(1));
            theServiceBus.DelaySend(message3, theClock.UtcNow().AddHours(2));
            theServiceBus.DelaySend(message4, theClock.UtcNow().AddHours(2));
        }
        public void single_message_for_single_handler_one()
        {
            handler<OneHandler, TwoHandler, ThreeHandler, FourHandler>();

            var theMessage = new OneMessage();
            sendMessage(theMessage);

            TestMessageRecorder.AllProcessed.Single()
                               .ShouldMatch<OneHandler>(theMessage);
        }
        public void single_message_for_single_handler_one()
        {
            handler <OneHandler, TwoHandler, ThreeHandler, FourHandler>();

            var theMessage = new OneMessage();

            sendMessage(theMessage);

            TestMessageRecorder.AllProcessed.Single()
            .ShouldMatch <OneHandler>(theMessage);
        }
Exemple #10
0
        public void multiple_handlers_should_fire_for_message()
        {
            handler<OneHandler, DifferentOneHandler, AnotherOneHandler, TwoHandler>();

            var theMessage = new OneMessage();
            sendMessage(theMessage);

            TestMessageRecorder.AllProcessed.Count().ShouldEqual(3);
            TestMessageRecorder.AllProcessed.ElementAt(0).ShouldMatch<OneHandler>(theMessage);
            TestMessageRecorder.AllProcessed.ElementAt(1).ShouldMatch<DifferentOneHandler>(theMessage);
            TestMessageRecorder.AllProcessed.ElementAt(2).ShouldMatch<AnotherOneHandler>(theMessage);
        }
Exemple #11
0
        public void multiple_handlers_should_fire_for_message()
        {
            handler <OneHandler, DifferentOneHandler, AnotherOneHandler, TwoHandler>();

            var theMessage = new OneMessage();

            sendMessage(theMessage);

            TestMessageRecorder.AllProcessed.Count().ShouldEqual(3);
            TestMessageRecorder.AllProcessed.ElementAt(0).ShouldMatch <OneHandler>(theMessage);
            TestMessageRecorder.AllProcessed.ElementAt(1).ShouldMatch <DifferentOneHandler>(theMessage);
            TestMessageRecorder.AllProcessed.ElementAt(2).ShouldMatch <AnotherOneHandler>(theMessage);
        }
Exemple #12
0
        public void SendMessage(string phoneNumber, ulong customerNumber, string messageText, int userId, int messageType)
        {
            var message = new OneMessage();

            message.PhoneNumber           = phoneNumber;
            message.CustomerNumber        = customerNumber;
            message.Message               = messageText;
            message.RegistrationSetNumber = userId;
            message.MessageType           = messageType;
            message.Source     = 1;
            message.ExternalId = null;
            this.Use(client =>
            {
                client.SendOneMessageAsync(message).Wait();
            }
                     );
        }
        public void generic_handler_is_applied_at_end()
        {
            handler <OneHandler, TwoHandler, ThreeHandler, GenericHandler>();
            handler <MyBatchHandler>();

            var message1 = new OneMessage();
            var message2 = new TwoMessage();
            var message3 = new ThreeMessage();

            sendOneMessage(new MyBatch(message1, message2, message3));

            TestMessageRecorder.AllProcessed.Count().ShouldEqual(6);
            TestMessageRecorder.AllProcessed[0].ShouldMatch <OneHandler>(message1);
            TestMessageRecorder.AllProcessed[1].ShouldMatch <GenericHandler>(message1);
            TestMessageRecorder.AllProcessed[2].ShouldMatch <TwoHandler>(message2);
            TestMessageRecorder.AllProcessed[3].ShouldMatch <GenericHandler>(message2);
            TestMessageRecorder.AllProcessed[4].ShouldMatch <ThreeHandler>(message3);
            TestMessageRecorder.AllProcessed[5].ShouldMatch <GenericHandler>(message3);
        }
Exemple #14
0
        public void generic_handler_is_applied_at_end()
        {
            handler<OneHandler, TwoHandler, ThreeHandler, GenericHandler>();

            var message1 = new OneMessage();
            var message2 = new TwoMessage();
            var message3 = new ThreeMessage();

            sendMessage(message1);
            sendMessage(message2);
            sendMessage(message3);

            TestMessageRecorder.AllProcessed.Count().ShouldEqual(6);
            TestMessageRecorder.AllProcessed[0].ShouldMatch<OneHandler>(message1);
            TestMessageRecorder.AllProcessed[1].ShouldMatch<GenericHandler>(message1);
            TestMessageRecorder.AllProcessed[2].ShouldMatch<TwoHandler>(message2);
            TestMessageRecorder.AllProcessed[3].ShouldMatch<GenericHandler>(message2);
            TestMessageRecorder.AllProcessed[4].ShouldMatch<ThreeHandler>(message3);
            TestMessageRecorder.AllProcessed[5].ShouldMatch<GenericHandler>(message3);
        }
Exemple #15
0
        protected sealed override void beforeEach()
        {
            theData     = new byte[] { 1, 2, 3, 4 };
            theMessage  = new OneMessage();
            theCallback = MockFor <IMessageCallback>();
            theHeaders  = new NameValueHeaders();

            theLogger = new RecordingLogger();

            theEnvelope = new Envelope(theData, theHeaders, theCallback)
            {
                Message = theMessage
            };
            theEnvelope.Message.ShouldBeTheSameAs(theMessage);

            Services.Inject <ILogger>(theLogger);

            Services.PartialMockTheClassUnderTest();
            theContextIs();
        }
Exemple #16
0
        public async Task Should_retry_each_message_type()
        {
            var pingMessage = new OneMessage {
                CorrelationId = NewId.NextGuid()
            };

            Task <ConsumeContext <Fault <OneMessage> > > pingFault =
                SubscribeHandler <Fault <OneMessage> >(x => x.Message.Message.CorrelationId == pingMessage.CorrelationId);
            Task <ConsumeContext <Fault <TwoMessage> > > pongFault =
                SubscribeHandler <Fault <TwoMessage> >(x => x.Message.Message.CorrelationId == pingMessage.CorrelationId);

            await InputQueueSendEndpoint.Send(pingMessage, x => x.FaultAddress = Bus.Address);

            await InputQueueSendEndpoint.Send(new TwoMessage { CorrelationId = pingMessage.CorrelationId }, x => x.FaultAddress = Bus.Address);

            ConsumeContext <Fault <OneMessage> > pingFaultContext = await pingFault;
            ConsumeContext <Fault <TwoMessage> > pongFaultContext = await pongFault;

            Assert.That(_consumer.PingCount, Is.EqualTo(3));
            Assert.That(_consumer.PongCount, Is.EqualTo(3));
        }
        public void send_now_is_handled_right_now()
        {
            using (var runtime = FubuRuntime.For<FubuRegistry>(x =>
            {
                x.ServiceBus.Enable(true);
                x.ServiceBus.EnableInMemoryTransport();
                x.Handlers.DisableDefaultHandlerSource();
                x.Handlers.Include<SimpleHandler<OneMessage>>();
            }))
            {
                var serviceBus = runtime.Get<IServiceBus>();

                TestMessageRecorder.Clear();

                var message = new OneMessage();

                serviceBus.Consume(message);

                TestMessageRecorder.ProcessedFor<OneMessage>().Single().Message
                    .ShouldBeTheSameAs(message);
            }
        }
Exemple #18
0
        public void send_now_is_handled_right_now()
        {
            using (var runtime = FubuRuntime.For <FubuRegistry>(x =>
            {
                x.ServiceBus.Enable(true);
                x.ServiceBus.EnableInMemoryTransport();
                x.Handlers.DisableDefaultHandlerSource();
                x.Handlers.Include <SimpleHandler <OneMessage> >();
            }))
            {
                var serviceBus = runtime.Get <IServiceBus>();

                TestMessageRecorder.Clear();

                var message = new OneMessage();

                serviceBus.Consume(message);

                TestMessageRecorder.ProcessedFor <OneMessage>().Single().Message
                .ShouldBeTheSameAs(message);
            }
        }
        public void send_now_is_handled_right_now()
        {
            using (var container = new Container())
            {
                using (var runtime = FubuTransport.For(x => {
                    x.EnableInMemoryTransport();
                    x.Handlers.DisableDefaultHandlerSource();
                    x.Handlers.Include <SimpleHandler <OneMessage> >();
                }).StructureMap(container).Bootstrap())

                {
                    var serviceBus = container.GetInstance <IServiceBus>();

                    TestMessageRecorder.Clear();

                    var message = new OneMessage();

                    serviceBus.Consume(message);

                    TestMessageRecorder.ProcessedFor <OneMessage>().Single().Message
                    .ShouldBeTheSameAs(message);
                }
            }
        }
Exemple #20
0
        public void send_now_is_handled_right_now()
        {
            using (var container = new Container())
            {
                using (var runtime = FubuTransport.For(x => {
                    x.EnableInMemoryTransport();
                    x.Handlers.DisableDefaultHandlerSource();
                                           x.Handlers.Include<SimpleHandler<OneMessage>>();
                }).StructureMap(container).Bootstrap())

                {
                    var serviceBus = container.GetInstance<IServiceBus>();

                    TestMessageRecorder.Clear();

                    var message = new OneMessage();

                    serviceBus.Consume(message);

                    TestMessageRecorder.ProcessedFor<OneMessage>().Single().Message
                        .ShouldBeTheSameAs(message);
                }
            }
        }
        protected override void beforeEach()
        {
            theMessage = new OneMessage();

            ClassUnderTest.InvokeNow(theMessage);
        }