public void CheckIfContainedBeforeAndAfterDequeuing() { var queue = new ArrayQueue <int>(); int itemCount = 10000; for (int i = 0; i < itemCount; i++) { if (queue.Contains(i)) { Assert.Fail(); } queue.Enqueue(i); if (!queue.Contains(i)) { Assert.Fail(); } } int lastItem = int.MinValue; for (int i = 0; i < itemCount; i++) { var first = queue.Peek(); if (!queue.Contains(i)) { Assert.Fail(); } var dequeued = queue.Dequeue(); if (dequeued != first) { Assert.Fail(); } if (lastItem > dequeued) { Assert.Fail(); } if (queue.Contains(i)) { Assert.Fail(); } lastItem = first; } Assert.IsTrue(queue.Count == 0); }
public void CheckContainsQueue() { MyQueue <int> queueArray = new ArrayQueue <int>(); MyQueue <int> queueList = new ListQueue <int>(); for (int i = 1; i < 6; i++) { queueArray.Enqueue(i); queueList.Enqueue(i); } var resultArray = queueArray.Contains(1); var resultList = queueList.Contains(1); Assert.True(resultArray); Assert.True(resultList); }
public void QueueContains() { Assert.IsTrue(queue.Contains("AThousandSuns")); Assert.IsTrue(queue.Contains("TheHuntingParty")); }