Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public void PeekMessageWithTimeOutWorks()
        {
            // --- Arrange
            var testQueue = new MemoryNamedQueue("name");
            testQueue.PutMessage("content", 10);
            testQueue.GetMessages(1, 5);

            // --- Act
            var expectedMessage = testQueue.PeekMessages(1);

            // --- Assert
            expectedMessage.ShouldHaveCountOf(0);
        }
Ejemplo n.º 3
0
        public void GetMessageInParallelWorks()
        {
            // --- Arrange
            var testQueue = new MemoryNamedQueue("name");
            testQueue.PutMessage("content1", 30);
            testQueue.PutMessage("content2", 30);
            testQueue.PutMessage("content3", 30);
            const int TO = 10;
            var result = new IEnumerable<IPoppedMessage>[TO];
            var expected = testQueue.PeekMessages(3);
            var expIdList = expected.Select(queuedMessage => queuedMessage.Id).ToList();

            // --- Act
            Parallel.For(0, TO, i => result[i] = testQueue.GetMessages(5, 20));

            // --- Assert
            var resultIdList = (
                from poppedMessage in result
                from message in poppedMessage
                select message.Id).ToList();

            foreach (var expId in expIdList)
            {
                var got = resultIdList.Count(resultId => expId == resultId);
                got.ShouldEqual(1);
            }
        }