public void RemoveItemFromMiddleOfFlexQueue() { // Arrange var queue = new FlexQueue<int>(); var entries = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }; var expEntriesWith5Removed = new List<int> { 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }; var expEntriesWith5and15Removed = new List<int> { 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20 }; var expEntriesWith5and15and1Removed = new List<int> { 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20 }; entries.ForEach(x => queue.Enqueue(x)); // Assert Assert.AreEqual(20, queue.Count); var firstItem = queue.RemoveAt(4); Assert.AreEqual(5, firstItem); Assert.AreEqual(19, queue.Count); Enumerable.Range(0, 19).ToList().ForEach(x => Assert.AreEqual(expEntriesWith5Removed[x], queue.PeekAt(x))); var secondItem = queue.RemoveAt(13); Assert.AreEqual(15, secondItem); Assert.AreEqual(18, queue.Count); Enumerable.Range(0, 18).ToList().ForEach(x => Assert.AreEqual(expEntriesWith5and15Removed[x], queue.PeekAt(x))); var thirdItem = queue.RemoveAt(0); Assert.AreEqual(1, thirdItem); Assert.AreEqual(17, queue.Count); Enumerable.Range(0, 17).ToList().ForEach(x => Assert.AreEqual(expEntriesWith5and15and1Removed[x], queue.PeekAt(x))); }
public void RemoveItemFromFlexQueueWhenOutOfRange() { // Arrange var queue = new FlexQueue<int>(); var entries = new List<int> { 1, 2 }; entries.ForEach(x => queue.Enqueue(x)); // Act queue.RemoveAt(20); }