public void TestStoppedConsumerHoldsMessagesTillStarted()
{
ISession startedSession = startedConnection.CreateSession(AcknowledgementMode.AutoAcknowledge);
ISession stoppedSession = stoppedConnection.CreateSession(AcknowledgementMode.AutoAcknowledge);
// Setup the consumers.
ITopic topic = startedSession.GetTopic("ConnectionTestTopic");
IMessageConsumer startedConsumer = startedSession.CreateConsumer(topic);
IMessageConsumer stoppedConsumer = stoppedSession.CreateConsumer(topic);
// Send the message.
IMessageProducer producer = startedSession.CreateProducer(topic);
ITextMessage message = startedSession.CreateTextMessage("Hello");
producer.Send(message);
// Test the assertions.
IMessage m = startedConsumer.Receive(TimeSpan.FromMilliseconds(1000));
Assert.IsNotNull(m);
m = stoppedConsumer.Receive(TimeSpan.FromMilliseconds(1000));
Assert.IsNull(m);
stoppedConnection.Start();
m = stoppedConsumer.Receive(TimeSpan.FromMilliseconds(5000));
Assert.IsNotNull(m);
startedSession.Close();
stoppedSession.Close();
}