public void Push_Pop_Peek_All_CorrectItem() { var ms = new MaxStack <int>(5); ms.Push(1); ms.Push(2); ms.Push(3); Assert.AreEqual(3, ms.Peek()); Assert.AreEqual(3, ms.Pop()); Assert.AreEqual(2, ms.Peek()); Assert.AreEqual(2, ms.Pop()); Assert.AreEqual(1, ms.Peek()); Assert.AreEqual(1, ms.Pop()); }
public void Peek_WhenEmpty_returnDefault() { var ms1 = new MaxStack <int>(5); Assert.AreEqual(0, ms1.Peek()); var ms2 = new MaxStack <string>(5); Assert.IsNull(ms2.Peek()); }
public void PushMoreThenMax_ExcessIsLost() { var ms = new MaxStack <string>(2); ms.Push("1"); ms.Push("2"); ms.Push("3"); Assert.AreEqual("3", ms.Pop()); Assert.AreEqual("2", ms.Pop()); Assert.IsNull(ms.Peek()); }
public void Grow_AddSpaceAtEnd() { var ms = new MaxStack <int>(2); ms.Push(1); ms.Push(2); ms.Grow(0.5f); Assert.AreEqual(3, ms.MaxSize); Assert.AreEqual(2, ms.Pop()); Assert.AreEqual(1, ms.Pop()); Assert.AreEqual(0, ms.Peek()); }
public void RemoveItem_GivesCorrectSequence() { var ms = new MaxStack <string>(3); ms.Push("1"); ms.Push("2"); ms.Push("3"); ms.Remove("2"); Assert.AreEqual("3", ms.Pop()); Assert.AreEqual("1", ms.Pop()); Assert.IsNull(ms.Peek()); }
public void Shrink_ExcessIsLost() { var ms = new MaxStack <int>(4); ms.Push(1); ms.Push(2); ms.Push(3); ms.Push(4); ms.Shrink(0.5f); Assert.AreEqual(2, ms.MaxSize); Assert.AreEqual(4, ms.Pop()); Assert.AreEqual(3, ms.Pop()); Assert.AreEqual(0, ms.Peek()); }