public async Task DequeueTwoItems() { // Arrange PersistedQueue <int> queue = CreatePersistedQueue <int>(inMemoryCapacity: 1); queue.Enqueue(0); queue.Enqueue(1); // Act / Assert Assert.Equal(0, await queue.DequeueAsync()); Assert.Equal(1, await queue.DequeueAsync()); }
private async Task LargeData() { for (int i = 0; i < totalItems; i++) { largeQueue.Enqueue(new LargeData()); } for (int i = 0; i < totalItems; i++) { await largeQueue.DequeueAsync(); } }
private async Task Int() { for (int i = 0; i < totalItems; i++) { smallQueue.Enqueue(i); } for (int i = 0; i < totalItems; i++) { await smallQueue.DequeueAsync(); } }
public async Task Dequeue(int numberOfItems) { // Arrange PersistedQueue <int> queue = CreatePersistedQueue <int>(); for (int i = 0; i < numberOfItems; i++) { queue.Enqueue(i); } // Act / Assert for (int i = 0; i < numberOfItems; i++) { Assert.Equal(i, await queue.DequeueAsync()); } }
private async Task InMemoryInt() { IPersistence <int> persistence = new InMemoryPersistence <int>(); PersistedQueueConfiguration config = new PersistedQueueConfiguration { MaxItemsInMemory = itemsToKeepInMemory }; PersistedQueue <int> queue = new PersistedQueue <int>(persistence, config); for (int i = 0; i < totalItems; i++) { queue.Enqueue(i); } for (int i = 0; i < totalItems; i++) { await queue.DequeueAsync(); } }
public void Count(int numberOfItems) { // Arrange PersistedQueue <int> queue = CreatePersistedQueue <int>(); for (int i = 0; i < numberOfItems; i++) { queue.Enqueue(i); } // Act / Assert for (int i = 0; i < numberOfItems; i++) { Assert.Equal(numberOfItems - i, queue.Count); queue.DequeueAsync(); } Assert.Empty(queue); }
public async Task should_queue_and_dequeue_items(string queueName, DataStore store, SerializationType serializationType) { Setup(queueName, store); for (int j = 0; j < 5; j++) { await _persistedQueue.EnqueueAsync(new ComplexType { Id = TestData.RandomAlphaString(), Name = TestData.RandomAlphaString() }); } var totalCount = await _persistedQueue.GetTotalCountAsync(); Assert.AreEqual(5, totalCount); while (true) { var dequeuedItem = await _persistedQueue.DequeueAsync(); if (dequeuedItem == null) { break; } await _persistedQueue.AcknowledgeAsync(dequeuedItem.AcknowledgeId); } var ackCount = await _persistedQueue.GetAcknowledgedCountAsync(); Assert.AreEqual(5, ackCount); var pendingCount = await _persistedQueue.GetPendingCountAsync(); Assert.AreEqual(0, pendingCount); await _persistedQueue.PurgeAsync(); totalCount = await _persistedQueue.GetTotalCountAsync(); Assert.AreEqual(0, totalCount); }