public void DynamicReplyChannel()
 {
     QueueChannel replyChannel1 = new QueueChannel();
     QueueChannel replyChannel2 = new QueueChannel();
     replyChannel2.ObjectName = "replyChannel2";
     Object handler = new TestObject2();
     ServiceActivatingHandler endpoint = new ServiceActivatingHandler(handler, "Handle");
     TestChannelResolver channelResolver = new TestChannelResolver();
     channelResolver.AddChannel(replyChannel2);
     endpoint.ChannelResolver = channelResolver;
     IMessage testMessage1 = MessageBuilder.WithPayload("bar").SetReplyChannel(replyChannel1).Build();
     endpoint.HandleMessage(testMessage1);
     IMessage reply1 = replyChannel1.Receive(TimeSpan.FromMilliseconds(50));
     Assert.IsNotNull(reply1);
     Assert.That(reply1.Payload, Is.EqualTo("foobar"));
     IMessage reply2 = replyChannel2.Receive(TimeSpan.Zero);
     Assert.IsNull(reply2);
     IMessage testMessage2 =
         MessageBuilder.FromMessage(testMessage1).SetReplyChannelName("replyChannel2").Build();
     endpoint.HandleMessage(testMessage2);
     reply1 = replyChannel1.Receive(TimeSpan.Zero);
     Assert.IsNull(reply1);
     reply2 = replyChannel2.Receive(TimeSpan.Zero);
     Assert.IsNotNull(reply2);
     Assert.That(reply2.Payload, Is.EqualTo("foobar"));
 }
 public void ReturnAddressHeaderWithChannelName()
 {
     QueueChannel channel = new QueueChannel(1);
     channel.ObjectName = "testChannel";
     TestChannelResolver channelResolver = new TestChannelResolver();
     channelResolver.AddChannel(channel);
     ServiceActivatingHandler endpoint = CreateEndpoint();
     endpoint.ChannelResolver = channelResolver;
     IMessage message = MessageBuilder.WithPayload("foo")
         .SetReplyChannelName("testChannel").Build();
     endpoint.HandleMessage(message);
     IMessage reply = channel.Receive(TimeSpan.Zero);
     Assert.IsNotNull(reply);
     Assert.That(reply.Payload, Is.EqualTo("FOO"));
 }