public void DeleteGotMessageOnSameThreadWorks()
        {
            // --- Arrange
            var testQueue = new MemoryNamedQueue("name");
            testQueue.PutMessage("content", 30);

            // --- Act

            var gotmsg = testQueue.GetMessages(1, 30).ToArray()[0];
            testQueue.DeleteMessage(gotmsg);

            // --- Assert
            testQueue.PeekMessages(3).Count().ShouldEqual(0);
        }
        public void GetApproximateMessageCountWorks()
        {
            // --- Arrange
            var testQueue = new MemoryNamedQueue("name");
            testQueue.PutMessage("content1", 30);
            testQueue.PutMessage("content2", 30);
            testQueue.PutMessage("content3", 30);

            // --- Act
            var count1 = testQueue.GetApproximateMessageCount();
            var messages = testQueue.GetMessages(2, 30).ToList();
            var count2 = testQueue.GetApproximateMessageCount();
            // ReSharper disable PossibleMultipleEnumeration
            testQueue.DeleteMessage(messages[0]);
            testQueue.DeleteMessage(messages[1]);
            // ReSharper restore PossibleMultipleEnumeration
            var count3 = testQueue.GetApproximateMessageCount();

            // --- Assert
            count1.ShouldEqual(3);
            count2.ShouldEqual(3);
            count3.ShouldEqual(1);
        }
        public void DeleteGotMessageOnDifferentThreadsFails()
        {
            // --- Arrange
            var testQueue = new MemoryNamedQueue("name");
            testQueue.PutMessage("content", 30);
            var getTask = new Task(() =>
            {
                Thread.Sleep(1050);
                testQueue.GetMessages(1, 20);
            });

            // --- Act
            var msg = testQueue.GetMessages(1, 1).ToArray()[0];
            getTask.Start();
            Thread.Sleep(1200);
            testQueue.DeleteMessage(msg);

            // --- Assert
            getTask.Wait();
        }