public void Stack_Count_ReturnsZeroIfStackIsEmpty() { Stack stack = new Stack(); int expectedNumberOfItems = 0; int stackCountValue = stack.Count(); Assert.AreEqual(expectedNumberOfItems, stackCountValue); }
public void Stack_IsEmpty_ReturnsFalseOnNonEmptyStack() { Stack stack = new Stack(); bool expectedIsEmptyReturnValue = false; stack.Push("Hello worldz"); stack.Push("Hi again"); bool actualIsEmptyReturnValue = stack.IsEmpty(); Assert.AreEqual(expectedIsEmptyReturnValue, actualIsEmptyReturnValue); }
public void Stack_Count_ReturnsZeroIfPreviouslyPopulatedStackIsEmpty() { Stack stack = new Stack(); int expectedNumberOfItems = 0; stack.Push("Some data"); stack.Pop(); int stackCountValue = stack.Count(); Assert.AreEqual(expectedNumberOfItems, stackCountValue); }
public void Stack_Count_ReturnsCorrectNumberOfItems() { Stack stack = new Stack(); int expectedNumberOfItems = 4; stack.Push("Data"); stack.Push("More data"); stack.Push("Even more data"); stack.Push("DATA"); int actualNumberOfItems = stack.Count(); Assert.AreEqual(expectedNumberOfItems, actualNumberOfItems); }
public void Stack_Count_ReturnsCorrectNumberOfItemsAfterMultiplePops() { Stack stack = new Stack(); int expectedNumberOfItems = 2; stack.Push("Data"); stack.Push("More data"); stack.Push("Even more data"); stack.Push("DATA"); stack.Push("DATAAA!!!!!"); stack.Pop(); stack.Pop(); stack.Pop(); int numberOfItemsAfterMultiplePops = stack.Count(); Assert.AreEqual(expectedNumberOfItems, numberOfItemsAfterMultiplePops); }
public void Stack_Pop_ThrowsExceptionWhenStackIsEmpty() { Stack stack = new Stack(); stack.Pop(); }
public void Stack_Pop_ThrowsExceptionWhenPreviouslyPopulatedStackIsEmpty() { Stack stack = new Stack(); stack.Push("Some data"); stack.Push("More data"); // Pop the existing items stack.Pop(); stack.Pop(); // No items left, try Pop again stack.Pop(); }
public void Stack_IsEmpty_ReturnsTrueOnPreviouslyPopulatedEmptyStack() { Stack stack = new Stack(); bool expectedIsEmptyReturnValue = true; stack.Push("Dataz"); stack.Push("More dataz"); stack.Pop(); stack.Pop(); bool actualIsEmptyReturnValue = stack.IsEmpty(); Assert.AreEqual(actualIsEmptyReturnValue, expectedIsEmptyReturnValue); }
public void Stack_Push_MultipleItemsToEmptyStack() { Stack stack = new Stack(); int expectedStackCount = 3; stack.Push("First item"); stack.Push("Second item"); stack.Push("Third item"); int actualStackCount = stack.Count(); Assert.AreEqual(expectedStackCount, actualStackCount); }
public void Stack_Pop_RemovesNodeFromStackWithOnlyOneNode() { Stack stack = new Stack(); int expectedCount = 0; stack.Push("Item to be popped"); stack.Pop(); int actualCount = stack.Count(); Assert.AreEqual(expectedCount, actualCount); }
public void Stack_Peek_ThrowsExceptionIfStackIsEmpty() { Stack stack = new Stack(); stack.Peek(); }
public void Stack_Peek_ThrowsExceptionIfPreviouslyPopulatedStackIsEmpty() { Stack stack = new Stack(); stack.Push("Some data"); stack.Push("More data"); stack.Pop(); stack.Pop(); stack.Peek(); }
public void Stack_Peek_ReturnsLastAddedItem() { Stack stack = new Stack(); String lastStackItemValue = "Last item value"; stack.Push("First item"); stack.Push("Second item"); stack.Push(lastStackItemValue); String peekValue = stack.Peek(); Assert.AreEqual(lastStackItemValue, peekValue); }
public void Stack_Peek_DoesntRemoveNode() { Stack stack = new Stack(); stack.Push("First Item"); stack.Push("Second Item"); int countBeforePeeking = stack.Count(); stack.Peek(); int countAfterPeeking = stack.Count(); Assert.AreEqual(countBeforePeeking, countAfterPeeking); }
public void Stack_Push_ItemToEmptyStack() { Stack stack = new Stack(); int expectedStackCount = 1; stack.Push("This is a string :)"); int actualStackCount = stack.Count(); Assert.AreEqual(expectedStackCount, actualStackCount); }
public void Stack_Push_ItemToPreviouslyPopulatedEmptyStack() { Stack stack = new Stack(); int expectedStackCount = 1; stack.Push("This is a string :)"); stack.Push("This is another string :)"); stack.Pop(); stack.Pop(); stack.Push("Some data"); int actualStackCount = stack.Count(); Assert.AreEqual(expectedStackCount, actualStackCount); }
public void Stack_Pop_ReturnsCorrectValueForMultiplePops() { Stack stack = new Stack(); String[] stackValues = { "data 1", "data 2", "data 3", "data 4" }; foreach (String valueToAdd in stackValues) { stack.Push(valueToAdd); } Array.Reverse(stackValues); foreach (String expectedValue in stackValues) { String actualValue = stack.Pop(); Assert.AreEqual(expectedValue, actualValue); } }
public void Stack_Push_MultipleItemsToStackAfterMultiplePops() { Stack stack = new Stack(); int expectedStackCount = 3; stack.Push("First item"); stack.Push("Second item"); stack.Push("Third item"); stack.Pop(); stack.Pop(); stack.Push("Hello"); stack.Push("Last item"); int actualStackCount = stack.Count(); Assert.AreEqual(expectedStackCount, actualStackCount); }
public void Stack_Pop_ReturnsCorrectValueFromStackWithMultipleItems() { Stack stack = new Stack(); String expectedPopValue = "Something"; stack.Push("Random data"); stack.Push("More random data"); stack.Push(expectedPopValue); String actualPopValue = stack.Pop(); Assert.AreEqual(expectedPopValue, actualPopValue); }
public void Stack_Pop_ReturnsCorrectValueFromStackWithMultipleItemsAfterPoppingThenPushing() { Stack stack = new Stack(); String expectedPopValue = "Something"; stack.Push("Random data"); stack.Push("More random data"); stack.Push("Some data that will be popped"); stack.Push("Some more data that will be popped"); stack.Pop(); stack.Pop(); stack.Push(expectedPopValue); String actualPopValue = stack.Pop(); Assert.AreEqual(expectedPopValue, actualPopValue); }
public void Stack_Pop_ReturnsCorrectValueFromStackWithOnlyOneNode() { Stack stack = new Stack(); String itemValue = "This is the correct value"; stack.Push(itemValue); String popValue = stack.Pop(); Assert.AreEqual(itemValue, popValue); }
public void Stack_IsEmpty_ReturnsFalseOnNonEmptyStackAfterMultiplePops() { Stack stack = new Stack(); bool expectedIsEmptyReturnValue = false; stack.Push("Hello worldz"); stack.Push("Hi again"); stack.Push("Hi again, again"); stack.Push("Hi again, but I'll be popped soon :("); stack.Pop(); stack.Pop(); bool actualIsEmptyReturnValue = stack.IsEmpty(); Assert.AreEqual(expectedIsEmptyReturnValue, actualIsEmptyReturnValue); }
public void Stack_IsEmpty_ReturnsTrueOnNewlyCreatedStack() { Stack stack = new Stack(); bool expectedIsEmptyReturnValue = true; bool actualIsEmptyReturnValue = stack.IsEmpty(); Assert.AreEqual(expectedIsEmptyReturnValue, actualIsEmptyReturnValue); }