public void YeahItDoes() { var deliveryAttempts = 0; adapter.Handle<string>(str => { Interlocked.Increment(ref deliveryAttempts); throw new ApplicationException(RecognizableErrorMessage); }); adapter.Bus.SendLocal("HELLO MY FRIEND!!!!!2222"); var timeout = 5.Seconds(); Assert.That(resetEvent.WaitOne(timeout), Is.True, "Did not receive PoisonMessage event within {0} timeout", timeout); Assert.That(deliveryAttempts, Is.EqualTo(5), "Expected 5 failed delivery attempts to have been made"); // be sure that message has moved and everything Thread.Sleep(1.Seconds()); using (var errorQueueClient = new AzureServiceBusMessageQueue(ConnectionString, ErrorQueueName)) { var receivedTransportMessage = errorQueueClient.ReceiveMessage(new NoTransaction()); Assert.That(receivedTransportMessage, Is.Not.Null); } }
static List<ReceivedTransportMessage> GetAllTheMessages(AzureServiceBusMessageQueue azureServiceBusMessageQueue, ITransactionContext transactionContext) { var messages = new List<ReceivedTransportMessage>(); ReceivedTransportMessage transportMessage; while ((transportMessage = azureServiceBusMessageQueue.ReceiveMessage(transactionContext)) != null) { messages.Add(transportMessage); } return messages; }