Exemplo n.º 1
0
        public void reading_settings()
        {
            var channel = new ChannelSettings
            {
                Outbound = new Uri("channel://outbound"),
                Downstream = new Uri("channel://downstream")
            };

            var bus = new BusSettings
            {
                Outbound = new Uri("bus://outbound"),
                Downstream = new Uri("bus://downstream")
            };

            var services = new InMemoryServiceLocator();
            services.Add(channel);
            services.Add(bus);

            var graph = new ChannelGraph();
            graph.ChannelFor<ChannelSettings>(x => x.Outbound);
            graph.ChannelFor<ChannelSettings>(x => x.Downstream);
            graph.ChannelFor<BusSettings>(x => x.Outbound);
            graph.ChannelFor<BusSettings>(x => x.Downstream);

            graph.ReadSettings(services);

            graph.ChannelFor<ChannelSettings>(x => x.Outbound)
                 .Uri.ShouldBe(channel.Outbound);
            graph.ChannelFor<ChannelSettings>(x => x.Downstream)
                 .Uri.ShouldBe(channel.Downstream);
            graph.ChannelFor<BusSettings>(x => x.Outbound)
                .Uri.ShouldBe(bus.Outbound);
            graph.ChannelFor<BusSettings>(x => x.Downstream)
                .Uri.ShouldBe(bus.Downstream);
        }
Exemplo n.º 2
0
        public void channel_for_by_accessor()
        {
            var graph = new ChannelGraph();
            var channelNode = graph.ChannelFor<ChannelSettings>(x => x.Outbound);
            channelNode
                 .ShouldBeTheSameAs(graph.ChannelFor<ChannelSettings>(x => x.Outbound));

            channelNode.Key.ShouldBe("Channel:Outbound");
            channelNode.SettingAddress.Name.ShouldBe("Outbound");
        }
        public void channel_for_by_accessor()
        {
            var graph       = new ChannelGraph();
            var channelNode = graph.ChannelFor <ChannelSettings>(x => x.Outbound);

            channelNode
            .ShouldBeTheSameAs(graph.ChannelFor <ChannelSettings>(x => x.Outbound));


            channelNode.Key.ShouldEqual("Channel:Outbound");
            channelNode.SettingAddress.Name.ShouldEqual("Outbound");
        }
        public void create_from_graph_and_run_through_the_channel()
        {
            using (var graph = new ChannelGraph())
            {
                var node = graph.ChannelFor<BusSettings>(x => x.Outbound);

                node.Uri = new Uri("memory://foo");

                var transport = new InMemoryTransport();
                transport.OpenChannels(graph);
                node.Channel.ShouldNotBeNull();

                var envelope = new Envelope();
                envelope.CorrelationId = Guid.NewGuid().ToString();
                envelope.Headers["Foo"] = "Bar";
                envelope.Data = new byte[] { 1, 2, 3, 4, 5 };

                var receiver = new RecordingReceiver();

                node.StartReceiving(receiver);

                node.Channel.Send(envelope.Data, envelope.Headers);

                Wait.Until(() => receiver.Received.Any(), timeoutInMilliseconds: 2000);

                var received = receiver.Received.Single();

                received.CorrelationId.ShouldEqual(envelope.CorrelationId);
                received.ContentType.ShouldEqual(envelope.ContentType);
                received.Data.ShouldEqual(envelope.Data);

            }
        }
        public void create_from_graph_and_run_through_the_channel()
        {
            using (var graph = new ChannelGraph())
            {
                var node = graph.ChannelFor <BusSettings>(x => x.Outbound);

                node.Uri = new Uri("memory://foo");

                var transport = new InMemoryTransport();
                transport.OpenChannels(graph);
                node.Channel.ShouldNotBeNull();

                var envelope = new Envelope();
                envelope.CorrelationId  = Guid.NewGuid().ToString();
                envelope.Headers["Foo"] = "Bar";
                envelope.Data           = new byte[] { 1, 2, 3, 4, 5 };

                var receiver = new RecordingReceiver();

                node.StartReceiving(receiver, new RecordingLogger());

                node.Channel.Send(envelope.Data, envelope.Headers);

                Wait.Until(() => receiver.Received.Any(), timeoutInMilliseconds: 2000);

                var received = receiver.Received.Single();

                received.CorrelationId.ShouldEqual(envelope.CorrelationId);
                received.ContentType.ShouldEqual(envelope.ContentType);
                received.Data.ShouldEqual(envelope.Data);
            }
        }
        public void start_receiving()
        {
            using (var graph = new ChannelGraph())
            {
                var node1 = graph.ChannelFor <ChannelSettings>(x => x.Upstream);
                var node2 = graph.ChannelFor <ChannelSettings>(x => x.Downstream);
                var node3 = graph.ChannelFor <BusSettings>(x => x.Upstream);
                var node4 = graph.ChannelFor <BusSettings>(x => x.Downstream);

                node1.Incoming = true;
                node2.Incoming = false;
                node3.Incoming = true;
                node4.Incoming = false;

                graph.Each(x => x.Channel = new FakeChannel());

                graph.StartReceiving(MockRepository.GenerateMock <IHandlerPipeline>());

                node1.Channel.As <FakeChannel>().ReceivedCount.ShouldBeGreaterThan(0);
                node2.Channel.As <FakeChannel>().ReceivedCount.ShouldEqual(0);
                node3.Channel.As <FakeChannel>().ReceivedCount.ShouldBeGreaterThan(0);
                node4.Channel.As <FakeChannel>().ReceivedCount.ShouldEqual(0);
            }
        }
        private void SetupTransport(string uri)
        {
            graph         = new ChannelGraph();
            node          = graph.ChannelFor <ChannelSettings>(x => x.Upstream);
            node.Uri      = new Uri(uri);
            node.Incoming = true;

            var delayedCache = new DelayedMessageCache <MessageId>();

            queues = new PersistentQueues(new RecordingLogger(), delayedCache, new LightningQueueSettings());
            queues.ClearAll();
            transport = new LightningQueuesTransport(queues, new LightningQueueSettings(), delayedCache);

            transport.OpenChannels(graph);
        }
        private void SetupTransport(string uri, ChannelMode mode)
        {
            graph = new ChannelGraph();
            node = graph.ChannelFor<ChannelSettings>(x => x.Upstream);
            node.Mode = mode;

            node.Uri = new Uri(uri);
            node.Incoming = true;

            var delayedCache = new DelayedMessageCache<MessageId>();
            queues = new PersistentQueues(new RecordingLogger());
            queues.ClearAll();
            transport = new LightningQueuesTransport(queues, new LightningQueueSettings());

            transport.OpenChannels(graph);
        }
        public void reading_settings()
        {
            var channel = new ChannelSettings
            {
                Outbound   = new Uri("channel://outbound"),
                Downstream = new Uri("channel://downstream")
            };

            var bus = new BusSettings
            {
                Outbound   = new Uri("bus://outbound"),
                Downstream = new Uri("bus://downstream")
            };

            var services = new InMemoryServiceLocator();

            services.Add(channel);
            services.Add(bus);

            var graph = new ChannelGraph();

            graph.ChannelFor <ChannelSettings>(x => x.Outbound);
            graph.ChannelFor <ChannelSettings>(x => x.Downstream);
            graph.ChannelFor <BusSettings>(x => x.Outbound);
            graph.ChannelFor <BusSettings>(x => x.Downstream);

            graph.ReadSettings(services);

            graph.ChannelFor <ChannelSettings>(x => x.Outbound)
            .Uri.ShouldEqual(channel.Outbound);
            graph.ChannelFor <ChannelSettings>(x => x.Downstream)
            .Uri.ShouldEqual(channel.Downstream);
            graph.ChannelFor <BusSettings>(x => x.Outbound)
            .Uri.ShouldEqual(bus.Outbound);
            graph.ChannelFor <BusSettings>(x => x.Downstream)
            .Uri.ShouldEqual(bus.Downstream);
        }
        public void can_be_used_after_clearing_all_messages()
        {
            using (var graph = new ChannelGraph())
            {
                var node = graph.ChannelFor<BusSettings>(x => x.Outbound);
                node.Uri = new Uri("memory://foo");

                var transport = new InMemoryTransport();
                transport.OpenChannels(graph);

                var receiver = new RecordingReceiver();
                node.StartReceiving(receiver);

                node.Channel.Send(new byte[] { 1, 2 }, new NameValueHeaders());

                transport.ClearAll();

                node.Channel.Send(new byte[] { 3, 4 }, new NameValueHeaders());

                Wait.Until(() => receiver.Received.Count == 2);
                receiver.Received.ShouldHaveCount(2);
            }
        }
        public void can_be_used_after_clearing_all_messages()
        {
            using (var graph = new ChannelGraph())
            {
                var node = graph.ChannelFor <BusSettings>(x => x.Outbound);
                node.Uri = new Uri("memory://foo");

                var transport = new InMemoryTransport();
                transport.OpenChannels(graph);

                var receiver = new RecordingReceiver();
                node.StartReceiving(receiver, new RecordingLogger());

                node.Channel.Send(new byte[] { 1, 2 }, new NameValueHeaders());

                transport.ClearAll();

                node.Channel.Send(new byte[] { 3, 4 }, new NameValueHeaders());

                Wait.Until(() => receiver.Received.Count == 2);
                receiver.Received.ShouldHaveCount(2);
            }
        }
Exemplo n.º 12
0
        public void start_receiving()
        {
            using (var graph = new ChannelGraph())
            {
                var node1 = graph.ChannelFor<ChannelSettings>(x => x.Upstream);
                var node2 = graph.ChannelFor<ChannelSettings>(x => x.Downstream);
                var node3 = graph.ChannelFor<BusSettings>(x => x.Upstream);
                var node4 = graph.ChannelFor<BusSettings>(x => x.Downstream);

                node1.Incoming = true;
                node2.Incoming = false;
                node3.Incoming = true;
                node4.Incoming = false;

                graph.Each(x => x.Channel = new FakeChannel());

                graph.StartReceiving(MockRepository.GenerateMock<IHandlerPipeline>(), new RecordingLogger());

                node1.Channel.As<FakeChannel>().ReceivedCount.ShouldBeGreaterThan(0);
                node2.Channel.As<FakeChannel>().ReceivedCount.ShouldBe(0);
                node3.Channel.As<FakeChannel>().ReceivedCount.ShouldBeGreaterThan(0);
                node4.Channel.As<FakeChannel>().ReceivedCount.ShouldBe(0);
            }
        }
        public void start_receiving()
        {
            using (var graph = new ChannelGraph())
            {
                var node1 = graph.ChannelFor<ChannelSettings>(x => x.Upstream);
                var node2 = graph.ChannelFor<ChannelSettings>(x => x.Downstream);
                var node3 = graph.ChannelFor<BusSettings>(x => x.Upstream);
                var node4 = graph.ChannelFor<BusSettings>(x => x.Downstream);

                node1.Incoming = true;
                node2.Incoming = false;
                node3.Incoming = true;
                node4.Incoming = false;

                graph.Each(x => x.Channel = MockRepository.GenerateMock<IChannel>());

                graph.StartReceiving(MockRepository.GenerateMock<IHandlerPipeline>());

                node1.Channel.AssertWasCalled(x => x.Receive(null), x => x.IgnoreArguments());
                node2.Channel.AssertWasNotCalled(x => x.Receive(null), x => x.IgnoreArguments());
                node3.Channel.AssertWasCalled(x => x.Receive(null), x => x.IgnoreArguments());
                node4.Channel.AssertWasNotCalled(x => x.Receive(null), x => x.IgnoreArguments());

            }
        }
        public void Setup()
        {
            graph = new ChannelGraph();
            node = graph.ChannelFor<ChannelSettings>(x => x.Upstream);
            node.Uri = new Uri("lq.tcp://localhost:2020/upstream");
            node.Incoming = true;

            var delayedCache = new DelayedMessageCache<MessageId>();
            queues = new PersistentQueues(new RecordingLogger(), delayedCache);
            queues.ClearAll();
            transport = new LightningQueuesTransport(queues, new LightningQueueSettings(), delayedCache);

            transport.OpenChannels(graph);
        }