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); }
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)); }
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); }