public void WHEN_receiving_message_THEN_can_send_new_message()
        {
            var secondReceiver = new TestableMessageReceiver(this.connectionFactory);

            this.sender.Send(new MessageForDelivery("message1"));

            var    waitEvent        = new AutoResetEvent(false);
            string receiver1Message = null;
            string receiver2Message = null;

            this.receiver.MessageReceived += (s, e) =>
            {
                waitEvent.Set();
                receiver1Message = e.Message.Body;
                waitEvent.WaitOne();
            };
            secondReceiver.MessageReceived += (s, e) =>
            {
                receiver2Message = e.Message.Body;
            };

            ThreadPool.QueueUserWorkItem(_ => { this.receiver.ReceiveMessage(); });

            Assert.True(waitEvent.WaitOne(TimeSpan.FromSeconds(10)));
            this.sender.Send(new MessageForDelivery("message2"));
            secondReceiver.ReceiveMessage();
            waitEvent.Set();

            Assert.Equal("message1", receiver1Message);
            Assert.Equal("message2", receiver2Message);
        }
        public GIVEN_sender_and_receiver()
        {
            this.connectionFactory = System.Data.Entity.Database.DefaultConnectionFactory;
            this.sender            = new MessageSender(this.connectionFactory, "TestSqlMessaging", "Test.Events");
            this.receiver          = new TestableMessageReceiver(this.connectionFactory);

            this.connectionString = this.connectionFactory.CreateConnection(this.dbName).ConnectionString;
            MessagingDbInitializer.CreateDatabaseObjects(this.connectionString, "Test", true);
        }