Exemplo n.º 1
0
        public void WhenAClientSubscribesToANonExistingQueue_TheQueueShouldBeCreatedAndTheClientShouldBeAdded()
        {
            var client = _listener.GetAConnectedClient();

            var message = new StompMessage("SUBSCRIBE");

            message["destination"] = "/queue/test";

            Assert.IsEmpty(_server.Queues);

            client.OnMessage(message);

            Assert.IsNotEmpty(_server.Queues);
            Assert.That(_server.Queues.First().Address.Equals("/queue/test"));
            Assert.That(_server.Queues.First().Clients.Contains(client));
        }
Exemplo n.º 2
0
        public void when_sending_a_message_to_a_unexisting_queue_the_message_should_be_stored()
        {
            var client = _listener.GetAConnectedClient();

            client.Send("hi there", "/new/queue");

            Assert.IsNotEmpty(_server.Queues, "there should be a queue");

            var queue = _server.Queues.First();

            Assert.IsEmpty(queue.Clients, "clients should be empty");
            Assert.IsTrue(queue.Store.HasMessages(), "queue should not be empty");

            string message;

            Assert.IsTrue(queue.Store.TryDequeue(out message));
            Assert.AreEqual(message, "hi there");
        }