Example #1
0
        public void GetWithTimeBasedPriorityAndOldTimestamp()
        {
            var messageOne = new BsonDocument {
                { "key", 0 }
            };
            var messageTwo = new BsonDocument {
                { "key", 1 }
            };
            var messageThree = new BsonDocument {
                { "key", 2 }
            };

            queue.Send(messageOne);
            queue.Send(messageTwo);
            queue.Send(messageThree);

            var resultTwo = queue.Get(new QueryDocument(), TimeSpan.MaxValue);

            //ensuring using old timestamp shouldn't affect normal time order of Send()s
            queue.AckSend(resultTwo.Handle, resultTwo.Payload, DateTime.UtcNow, 0.0, false);

            var resultOne = queue.Get(new QueryDocument(), TimeSpan.MaxValue);

            resultTwo = queue.Get(new QueryDocument(), TimeSpan.MaxValue);
            var resultThree = queue.Get(new QueryDocument(), TimeSpan.MaxValue);

            Assert.AreEqual(messageOne, resultOne.Payload);
            Assert.AreEqual(messageTwo, resultTwo.Payload);
            Assert.AreEqual(messageThree, resultThree.Payload);
        }