Beispiel #1
0
        public void SetUp()
        {
            databusForSiteA = new InMemoryDataBus();
            databusForSiteB = new InMemoryDataBus();

            inMemoryReceiver = new InMemoryReceiver();

            var builder = MockRepository.GenerateStub <IBuilder>();

            var channelFactory = new ChannelFactory();

            channelFactory.RegisterReceiver(typeof(HttpChannelReceiver));

            channelFactory.RegisterSender(typeof(HttpChannelSender));


            var channelManager = MockRepository.GenerateStub <IMangageReceiveChannels>();

            channelManager.Stub(x => x.GetReceiveChannels()).Return(new[] { new ReceiveChannel()
                                                                            {
                                                                                Address = HttpAddressForSiteB,
                                                                                Type    = "http",
                                                                                NumberOfWorkerThreads = 1
                                                                            } });
            channelManager.Stub(x => x.GetDefaultChannel()).Return(defaultChannelForSiteA);


            builder.Stub(x => x.Build <IdempotentChannelForwarder>()).Return(new IdempotentChannelForwarder(channelFactory)
            {
                DataBus = databusForSiteA
            });

            builder.Stub(x => x.Build <IReceiveMessagesFromSites>()).Return(new IdempotentChannelReceiver(channelFactory, new InMemoryPersistence())
            {
                DataBus = databusForSiteB
            });


            builder.Stub(x => x.BuildAll <IRouteMessagesToSites>()).Return(new[] { new KeyPrefixConventionSiteRouter() });

            messageSender   = new FakeMessageSender();
            receiverInSiteB = new GatewayReceiver(channelManager, new DefaultEndpointRouter
            {
                MainInputAddress = EndpointAddressForSiteB
            }, builder, messageSender);

            dispatcherInSiteA = new GatewaySender(builder,
                                                  channelManager,
                                                  MockRepository.GenerateStub <IMessageNotifier>(),
                                                  MockRepository.GenerateStub <ISendMessages>(),
                                                  new FakeDispatcherSettings
            {
                Receiver       = inMemoryReceiver,
                FailureManager = MockRepository.GenerateStub <IManageMessageFailures>()
            });

            dispatcherInSiteA.Start(GatewayAddressForSiteA);
            receiverInSiteB.Start(GatewayAddressForSiteB);
        }
        public void SetUp()
        {
            databusForSiteA = new InMemoryDataBus();
            databusForSiteB = new InMemoryDataBus();

            inMemoryReceiver = new InMemoryReceiver();

            var builder = MockRepository.GenerateStub<IBuilder>();

            var channelManager = MockRepository.GenerateStub<IMangageReceiveChannels>();
            channelManager.Stub(x => x.GetActiveChannels()).Return(new[] {new Channel
                                                                              {
                                                                                  NumWorkerThreads = 1,
                                                                                  ReceiveAddress = HttpAddressForSiteB,
                                                                                  Receiver = typeof(HttpChannelReceiver)
                                                                              }});
            channelManager.Stub(x => x.GetDefaultChannel()).Return(new Channel
                                                                       {
                                                                           NumWorkerThreads = 1,
                                                                           ReceiveAddress = HttpAddressForSiteA,
                                                                           Receiver = typeof(HttpChannelReceiver)
                                                                       });

            builder.Stub(x => x.Build<IdempotentSender>()).Return(new IdempotentSender(builder)
                                                                             {
                                                                                 DataBus = databusForSiteA
                                                                             });

            builder.Stub(x => x.Build<IReceiveMessagesFromSites>()).Return(new IdempotentReceiver(builder, new InMemoryPersistence()
                                                                                                               )
            {
                DataBus = databusForSiteB
            });

            builder.Stub(x => x.Build(typeof(HttpChannelReceiver))).Return(new HttpChannelReceiver());
            builder.Stub(x => x.Build(typeof(HttpChannelSender))).Return(new HttpChannelSender());

            builder.Stub(x => x.BuildAll<IRouteMessagesToSites>()).Return(new[] { new KeyPrefixConventionSiteRouter() });

            messageSender = new FakeMessageSender();
            receiverInSiteB = new GatewayReceiver(channelManager,new DefaultEndpointRouter
                                                                     {
                                                                         MainInputAddress = EndpointAddressForSiteB
                                                                     },builder,messageSender);

            dispatcherInSiteA = new GatewaySender(builder,
                                                                   channelManager,
                                                                   MockRepository.GenerateStub<IMessageNotifier>(),
                                                                   MockRepository.GenerateStub<ISendMessages>(),
                                                                   new FakeDispatcherSettings
                                                                       {
                                                                           Receiver = inMemoryReceiver
                                                                       });

            dispatcherInSiteA.Start(GatewayAddressForSiteA);
            receiverInSiteB.Start(GatewayAddressForSiteB);
        }
Beispiel #3
0
        public void SetUp()
        {
            databusForSiteA = new InMemoryDataBus();
            databusForSiteB = new InMemoryDataBus();
            fakeTransport = new FakeTransport();

            var builder = MockRepository.GenerateStub<IBuilder>();

            var channelFactory = new ChannelFactory();

            channelFactory.RegisterReceiver(typeof(HttpChannelReceiver));

            channelFactory.RegisterSender(typeof(HttpChannelSender));

            var channelManager = MockRepository.GenerateStub<IManageReceiveChannels>();
            channelManager.Stub(x => x.GetReceiveChannels()).Return(new[] {new ReceiveChannel()
                                                                              {
                                                                                  Address = HttpAddressForSiteB,
                                                                                  Type = "http",
                                                                                  NumberOfWorkerThreads = 1
                                                                              }});
            channelManager.Stub(x => x.GetDefaultChannel()).Return(defaultChannelForSiteA);

            builder.Stub(x => x.Build<IdempotentChannelForwarder>()).Return(new IdempotentChannelForwarder(channelFactory)
                                                                             {
                                                                                 DataBus = databusForSiteA
                                                                             });

            builder.Stub(x => x.Build<IReceiveMessagesFromSites>()).Return(new IdempotentChannelReceiver(channelFactory, new InMemoryPersistence())
            {
                DataBus = databusForSiteB
            });

            builder.Stub(x => x.BuildAll<IRouteMessagesToSites>()).Return(new[] { new KeyPrefixConventionSiteRouter() });

            messageSender = new FakeMessageSender();
            receiverInSiteB = new GatewayReceiver();
            receiverInSiteB.ChannelManager = channelManager;
            receiverInSiteB.EndpointRouter = new DefaultEndpointRouter
                {
                    MainInputAddress = EndpointAddressForSiteB
                };
            receiverInSiteB.MessageSender = messageSender;
            receiverInSiteB.builder = builder;
            //receiverInSiteB.InputAddress = GatewayAddressForSiteA;

            dispatcherInSiteA = new GatewaySender();
            dispatcherInSiteA.ChannelManager = channelManager;
            dispatcherInSiteA.Builder = builder;
            dispatcherInSiteA.MessageSender = MockRepository.GenerateStub<ISendMessages>();
            dispatcherInSiteA.Notifier = MockRepository.GenerateStub<IMessageNotifier>();
               // dispatcherInSiteA.InputAddress = GatewayAddressForSiteA;

            dispatcherInSiteA.Start();
            receiverInSiteB.Start();
        }