private void CompareList(List <int> _list, ZStackByList <int> stack) { Assert.AreEqual(_list.Count, stack.Count); List <int> stackList = stack.ToList(); stackList.Reverse(); CollectionAssert.AreEqual(_list, stackList); }
private ZStackByList <int> InitializeZStackByList() { ZStackByList <int> stack = new ZStackByList <int>(); for (int i = 0; i < list.Count; i++) { stack.Push(list[i]); } return(stack); }
public void ZStackByListTestReverse() { ZStackByList <int> stack = InitializeZStackByList(); List <int> _list = new List <int>() { 6, 5, 4, 3, 2, 1, 7, 8, 9, 10 }; _list.Reverse(); stack.Reverse(); CompareList(_list, stack); }
public void ZStackByListTestSort() { ZStackByList <int> stack = InitializeZStackByList(); List <int> _list = new List <int>() { 6, 5, 4, 3, 2, 1, 7, 8, 9, 10 }; _list.Sort(); stack.Sort(); Assert.AreEqual(_list.Count, stack.Count); CollectionAssert.AreEqual(_list, stack.ToList()); }
public void ZStackByListTestPop() { ZStackByList <int> stack = InitializeZStackByList(); Assert.AreEqual(10, stack.Pop()); Assert.AreEqual(9, stack.Pop()); Assert.AreEqual(8, stack.Pop()); Assert.AreEqual(7, stack.Pop()); Assert.AreEqual(1, stack.Pop()); Assert.AreEqual(2, stack.Pop()); Assert.AreEqual(3, stack.Pop()); Assert.AreEqual(4, stack.Pop()); Assert.AreEqual(5, stack.Pop()); Assert.AreEqual(6, stack.Pop()); Assert.AreEqual(0, stack.Count); }
public void ZStackByListTestPush() { ZStackByList <int> stack = InitializeZStackByList(); CompareList(list, stack); }