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 CorrelationIdNotSetIfMessageIsReturnedUnaltered()
 {
     QueueChannel replyChannel = new QueueChannel(1);
     ServiceActivatingHandler endpoint = new ServiceActivatingHandler(new TestObject3(), "Handle");
     IMessage message = MessageBuilder.WithPayload("test").SetReplyChannel(replyChannel).Build();
     endpoint.HandleMessage(message);
     IMessage reply = replyChannel.Receive(TimeSpan.FromMilliseconds(500));
     Assert.IsNull(reply.Headers.CorrelationId);
 }
 public void CorrelationIdSetByHandlerTakesPrecedence()
 {
     QueueChannel replyChannel = new QueueChannel(1);
     ServiceActivatingHandler endpoint = new ServiceActivatingHandler(new TestObject4(), "Handle");
     IMessage message = MessageBuilder.WithPayload("test").SetReplyChannel(replyChannel).Build();
     endpoint.HandleMessage(message);
     IMessage reply = replyChannel.Receive(TimeSpan.FromMilliseconds(500));
     Object correlationId = reply.Headers.CorrelationId;
     Assert.IsFalse(message.Headers.Id.Equals(correlationId));
     Assert.That(correlationId, Is.EqualTo("ABC-123"));
 }
 public void NoReplyMessageWithRequiresReply()
 {
     QueueChannel channel = new QueueChannel(1);
     ServiceActivatingHandler endpoint = new ServiceActivatingHandler(new TestNullReplyObject(), "Handle");
     endpoint.RequiresReply = true;
     endpoint.OutputChannel = channel;
     IMessage message = MessageBuilder.WithPayload("foo").Build();
     endpoint.HandleMessage(message);
 }
 public void NoReplyMessage()
 {
     QueueChannel channel = new QueueChannel(1);
     ServiceActivatingHandler endpoint = new ServiceActivatingHandler(new TestNullReplyObject(), "Handle");
     endpoint.OutputChannel = channel;
     IMessage message = MessageBuilder.WithPayload("foo").Build();
     endpoint.HandleMessage(message);
     Assert.IsNull(channel.Receive(TimeSpan.Zero));
 }