Ejemplo n.º 1
0
        public void SingleItemAheadOfQueueHeadTest()
        {
            queue = new SeriesQueue <MessageItem>(nextOrdinal: 4);
            var message = new MessageItem(new Message {
                Sequence = 10, Timestamp = DateTime.UtcNow, Data = "Message1"
            });
            var items = queue.AddAndDequeueAll(message);

            items.Should().BeEmpty();
            queue.Count.Should().Be(1);
        }
Ejemplo n.º 2
0
        public void SingleItemAtQueueHeadTest()
        {
            queue = new SeriesQueue <MessageItem>(nextOrdinal: 4);
            var message = new MessageItem(new Message {
                Sequence = 4, Timestamp = DateTime.UtcNow, Data = "Message4"
            });
            var items = queue.AddAndDequeueAll(message);

            items.Should().BeEquivalentTo(new[] { message });
            queue.Count.Should().Be(0);
        }
Ejemplo n.º 3
0
        public void ItemsInOrderTest()
        {
            var messages = new List <MessageItem>
            {
                new MessageItem(new Message {
                    Sequence = 0, Timestamp = DateTime.UtcNow, Data = "Message1"
                }),
                new MessageItem(new Message {
                    Sequence = 1, Timestamp = DateTime.UtcNow, Data = "Message2"
                }),
                new MessageItem(new Message {
                    Sequence = 2, Timestamp = DateTime.UtcNow, Data = "Message3"
                }),
            };

            queue.Enqueue(messages[0]);
            queue.Enqueue(messages[1]);

            var items = queue.AddAndDequeueAll(messages[2]);

            items.Should().BeEquivalentTo(messages);
        }