예제 #1
0
		public void Should_properly_arrive_at_the_destination()
		{
			var serviceUri = new Uri("net.pipe://localhost/pipe");
			string pipeName = "test";

			var future = new Future<TestMessage>();
			var message = new TestMessage
				{
					Id = Guid.NewGuid(),
					Name = "Alpha",
				};

			UntypedChannel adapter = new ChannelAdapter();
			using (var remote = new WcfChannelHost(new SynchronousFiber(), adapter, serviceUri, pipeName))
			{
				using (adapter.Connect(x =>
					{
						x.AddConsumerOf<TestMessage>()
							.UsingConsumer(m => future.Complete(m));
					}))
				{
					var client = new WcfChannelProxy(new SynchronousFiber(), serviceUri, pipeName);

					client.Send(message);

					future.WaitUntilCompleted(2.Seconds()).ShouldBeTrue();
				}
			}

			future.Value.ShouldNotBeNull();
			future.Value.ShouldEqual(message);
			future.Value.ShouldNotBeTheSameAs(message);
		}
예제 #2
0
		public void Connecting_two_services_through_a_wcf_proxy_and_host()
		{
			_pipeUri = new Uri("net.pipe://localhost/pipe");

			_consumer = new Future<TestMessage>();

			_input = new ChannelAdapter();
			_inputConnection = _input.Connect(x =>
				{
					x.AddConsumerOf<TestMessage>()
						.UsingConsumer(_consumer.Complete);
				});

			_host = new WcfChannelHost(new PoolFiber(), _input, _pipeUri, _pipeName);

			_output = new ChannelAdapter();
			_outputConnection = _output.Connect(x =>
				{
					x.SendToWcfChannel(_pipeUri, _pipeName)
						.HandleOnCallingThread();
				});
		}
예제 #3
0
        public void Should_property_adapt_itself_to_a_channel_network()
        {
            var serviceUri = new Uri("net.pipe://localhost/Pipe");
            string pipeName = "Test";
            Channel<TestMessage> adapter = new ChannelAdapter<TestMessage>();
            using (var host = new WcfChannelHost<TestMessage>(adapter, serviceUri, pipeName))
            {
                var future = new Future<TestMessage>();

                using (adapter.Connect(x =>
                    {
                        x.AddConsumer(future.Complete);
                    }))
                {
                    var client = new WcfChannelProxy<TestMessage>(new SynchronousFiber(), serviceUri, pipeName);

                    client.Send(new TestMessage("Hello!"));

                    future.WaitUntilCompleted(2.Seconds()).ShouldBeTrue();
                }
            }
        }
예제 #4
0
		public void After()
		{
			_host.Dispose();
			_host = null;

			_inputConnection.Dispose();
			_inputConnection = null;
			_input = null;

			_outputConnection.Dispose();
			_outputConnection = null;
			_output = null;
		}