public void PushingFullStack_ThrowsInvalidOperationException() { var stack = new GenericValueTypeStack <int>(1); stack.Push(0); stack.Push(1); }
static void Main(string[] args) { Console.WriteLine("Instantiating new GenericValueStack..."); GenericValueTypeStack <double> stack = new GenericValueTypeStack <double>(3); Console.WriteLine("Pushing value \"3.14\""); stack.Push(3.14); Console.WriteLine("Pushing value \"42\""); stack.Push(42); Console.WriteLine("Popping value..."); Console.WriteLine(string.Format("Popped value \"{0}\".", stack.Pop())); Console.WriteLine("Popping value..."); Console.WriteLine(string.Format("Popped value \"{0}\".", stack.Pop())); Console.ReadKey(); }
public void StackIsFirstInLastOut() { var size = 42; var stack = new GenericValueTypeStack <int>(size); for (int i = 0; i < size; i++) { stack.Push(i); } for (int i = size - 1; i >= 0; i--) { Assert.AreEqual(i, stack.Pop()); } }