public void PeekOrDefault() { Stack <int> stack = new Stack <int>(); Assert.AreEqual(0, StackUtility.PeekOrDefault(stack)); stack.Push(3); Assert.AreEqual(3, StackUtility.PeekOrDefault(stack)); stack.Pop(); Assert.AreEqual(0, StackUtility.PeekOrDefault(stack)); }
public void PeekOrDefaultWithDefault() { var stack = new Stack <int>(); Assert.AreEqual(1, StackUtility.PeekOrDefault(stack, 1)); stack.Push(3); Assert.AreEqual(3, StackUtility.PeekOrDefault(stack, 1)); stack.Pop(); Assert.AreEqual(1, StackUtility.PeekOrDefault(stack, 1)); }