public void PushTestOutofNumber() { try { StackTwo s = new StackTwo(); s.Push(0, 1); s.Push(0, 2); s.Push(0, 3); s.Push(0, 4); } catch (Exception e) { Assert.AreEqual("Out of space.", e.Message); } }
/// <summary> /// Helper method /// </summary> private void AlternateNodes() { int depth = Count; bool even = Count % 2 == 0; Stack tempStack = new Stack(); for (int i = 0; i < depth; i++) { if (even) { tempStack.Push(StackTwo.Pop()); } else { tempStack.Push(StackOne.Pop()); } } for (int j = 0; j < depth; j++) { if (even) { StackOne.Push(tempStack.Pop()); } else { StackTwo.Push(tempStack.Pop()); } } }
public void PeekTest() { StackTwo s = new StackTwo(); int expected = 5; // TODO: Initialize to an appropriate value int actual; s.Push(0, expected); actual = s.Peek(0); Assert.AreEqual(expected, actual); }
/// <summary> /// Enqueue method /// </summary> /// <param name="value">The value of which we are trying to "enqueue"</param> public void Enqueue(string value) { AlternateNodes(); if (Count % 2 != 0) { StackOne.Push(value); } else { StackTwo.Push(value); } Count++; }