Example #1
0
        public async Task NeverDequeuedItemCannotBeRemoved()
        {
            const int             item      = 0;
            const int             otherItem = 1;
            ProcessingQueue <int> queue     = new ProcessingQueue <int>(() => { });

            queue.Enqueue(item);
            await DelayDelta();

            // should throw because otherItem is not being processed yet
            queue.OnProcessed(otherItem);
        }
Example #2
0
        public async Task DequeuedItemIsInProcessingList()
        {
            const int             item  = 0;
            ProcessingQueue <int> queue = new ProcessingQueue <int>(() => { });

            queue.Enqueue(item);
            await DelayDelta();

            queue.TryDequeue(out int dequeuedItem);
            queue.OnProcessed(dequeuedItem);

            Assert.IsTrue(queue.CurrentlyProcessingTasks.Contains(dequeuedItem));
        }
Example #3
0
        public async Task DequeuedItemCanBeRemoved()
        {
            const int             item  = 0;
            ProcessingQueue <int> queue = new ProcessingQueue <int>(() => { });

            queue.Enqueue(item);
            await DelayDelta();

            queue.TryDequeue(out int dequeuedItem);

            // assertion is that the following does not throw
            queue.OnProcessed(dequeuedItem);

            Assert.AreEqual(0, queue.Count);
        }