Exemple #1
0
        public void TestMessageListenerCallsConnectionStopThrowsIllegalStateException()
        {
            using (TestAmqpPeer testAmqpPeer = new TestAmqpPeer(Address, User, Password))
            {
                testAmqpPeer.Open();
                testAmqpPeer.SendMessage("myQueue", "test");

                NmsConnection connection = (NmsConnection)EstablishConnection();
                connection.Start();
                ISession         session     = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
                IQueue           destination = session.GetQueue("myQueue");
                IMessageConsumer consumer    = session.CreateConsumer(destination);

                Exception exception = null;
                consumer.Listener += message =>
                {
                    try
                    {
                        connection.Stop();
                    }
                    catch (Exception e)
                    {
                        exception = e;
                    }
                };

                Assert.That(() => exception, Is.Not.Null.After(5000, 100));
                consumer.Close();
                session.Close();
                connection.Close();
            }
        }
Exemple #2
0
 public void TestConnectionStartAndStop()
 {
     connection = new NmsConnection(connectionInfo, provider);
     Assert.False(connection.IsConnected);
     connection.Start();
     Assert.True(connection.IsConnected);
     connection.Stop();
     Assert.True(connection.IsConnected);
 }