static void Main() { MyArrayStack<int> myStack = new MyArrayStack<int>(); for (int i = 1; i <= 10; i++) { myStack.Push(i); } Console.WriteLine("{0}", string.Join("-", myStack.ToArray())); foreach (var item in myStack) { Console.Write("{0}-", item); } Console.WriteLine(); while (myStack.Count > 0) { Console.WriteLine(myStack.Pop()); } Console.Read(); }
public void EmptyMyStack_ShouldReturnEmptyArray() { MyArrayStack<DateTime> myStack = new MyArrayStack<DateTime>(); var arr = myStack.ToArray(); Assert.AreEqual(0, arr.Length); }
public void TestToArrayMethod_ReturnedArrayShouldBeInReversedOrder() { MyArrayStack<int> myStack = new MyArrayStack<int>(); myStack.Push(3); myStack.Push(5); myStack.Push(-2); myStack.Push(7); var arr = myStack.ToArray(); Assert.AreEqual(7, arr[0]); Assert.AreEqual(-2, arr[1]); Assert.AreEqual(5, arr[2]); Assert.AreEqual(3, arr[3]); }