public void Enumerator_CollectionWasChanged_ExceptionExpected() { QueueN <int> q = new QueueN <int>(1); for (int i = 0; i < 10; i++) { q.Push(i); } Assert.Throws(typeof(InvalidOperationException), () => { foreach (var el in q) { q.Pop(); } }); Assert.Throws(typeof(InvalidOperationException), () => { foreach (var el in q) { q.Push(el); } }); }
public void Push_intArray_QueueWithElementsExpected (int[] data) { //arrange QueueN <int> q = new QueueN <int>(1); //act for (int i = 0; i < data.Length; i++) { q.Push(data[i]); } //assert CollectionAssert.AreEquivalent(data, q); }
public void CopyTo_ArrayExpected (int[] data, int[] destination, int index, int[] expectedArray) { //arrange QueueN <int> q = new QueueN <int>(1); for (int i = 0; i < data.Length; i++) { q.Push(data[i]); } //act q.CopyTo(destination, index); //assert CollectionAssert.AreEqual(expectedArray, destination); }
public void PushFrontPop_intArray_RightOrderOfElementsExpected (int[] data) { //arrange QueueN <int> q = new QueueN <int>(2); //act for (int i = 0; i < data.Length; i++) { q.Push(data[i]); } //assert for (int i = 0; i < data.Length; i++) { int actual = q.Front(); Assert.AreEqual(data[i], actual); q.Pop(); } Assert.AreEqual(true, q.Empty, "queue is not empty, but should be"); }