public void Dequeue_ValidInput_ValidCapacityAndSizeAndEnumerationOrderAfterResizing() { var elements = Enumerable.Range(1, 11).ToArray(); var q = new CustomQueue.Queue <int>(); foreach (int element in elements) { q.Enqueue(element); } q.Dequeue(); q.Dequeue(); q.Dequeue(); var zip = elements.Skip(3).Zip(q, (fromElements, fromQueue) => new { fromElements, fromQueue }); foreach (var value in zip) { if (value.fromElements != value.fromQueue) { Assert.Fail("Not valid elements"); } } if (q.Size != 8) { Assert.Fail($"Not valid size. Actual = {q.Size}"); } if (q.Capacity != 16) { Assert.Fail($"Not valid capacity. Actual = {q.Capacity}"); } }
public void Enumeration_DequeueInForeach_ThrowsInvalidOperationExc() { var q = new CustomQueue.Queue <int>(Enumerable.Range(1, 11)); Assert.Throws <InvalidOperationException>( () => { foreach (int _ in q) { q.Dequeue(); } }); }
public void EnqueueDequeue_SavesOrder() { var elements = Enumerable.Range(1, 20).ToArray(); var q = new CustomQueue.Queue <int>(); foreach (int element in elements) { q.Enqueue(element); } foreach (int element in elements) { if (element != q.Dequeue()) { Assert.Fail(); } } Assert.That(q.IsEmpty()); }