Beispiel #1
0
        public async Task ReloadWithData(int firstDequeue, int secondDequeue, int indexItemsPerPage = 30, int dataPageSize = 32 * 10)
        {
            var config = new UnitTestQueueConfiguration
            {
                IndexItemsPerPage = indexItemsPerPage,
                DataPageSize      = dataPageSize
            };

            try
            {
                using (var q1 = new Persistent.Queue.PersistentQueue(config))
                {
                    q1.EnqueueManySized(10, 32);
                    var result = await q1.DequeueAsync(1, firstDequeue);

                    result.Commit();
                }

                using (var q2 = new Persistent.Queue.PersistentQueue(config))
                {
                    q2.EnqueueManySized(10, 32);
                    var result = await q2.DequeueAsync(1, secondDequeue);

                    result.Commit();
                    q2.HasItems.ShouldBeFalse();
                }
            }
            finally
            {
                Directory.Delete(config.QueuePath, true);
            }
        }
Beispiel #2
0
        public static void Enqueue(this Persistent.Queue.PersistentQueue queue, int itemNo)
        {
            var s = Encoding.UTF8.GetBytes($"Message {itemNo}");

            queue.Enqueue(s);
        }
Beispiel #3
0
 public static void EnqueueManySized(this Persistent.Queue.PersistentQueue queue, int count, int byteSize)
 {
     Enumerable.Range(1, count)
     .ForEach(_ => queue.Enqueue(new byte[byteSize]));
 }
Beispiel #4
0
 public static void EnqueueMany(this Persistent.Queue.PersistentQueue queue, int count, int start = 1)
 {
     Enumerable.Range(start, count)
     .ForEach(queue.Enqueue);
 }