-
-
Save rsotto/9f607d9b76a910caefc4211c94340c7e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestClass()] | |
public class MyStackTests | |
{ | |
[TestMethod()] | |
public void ConstructorTest() | |
{ | |
var myStack = new MyStack<int>(); | |
Assert.IsTrue(myStack.Size == 0, "Expecting stack size to be 0 but is not."); | |
Assert.IsTrue(myStack.IsEmpty, "Expecting stack to be empty but is not."); | |
} | |
// ... | |
[TestMethod()] | |
public void PopTest() | |
{ | |
var myStack = new MyStack<double>(); | |
myStack.Push(1.5); | |
myStack.Push(3.2); | |
Assert.AreEqual(3.2, myStack.Pop(), "Expecting popped element to be 3.2 but is not."); | |
Assert.AreEqual(1.5, myStack.Pop(), "Expecting popped element to be 1.5 but is not."); | |
} | |
[TestMethod()] | |
public void PopIsEmptyTest() | |
{ | |
var myStack = new MyStack<int>(); | |
Assert.ThrowsException<InvalidOperationException>(delegate () { myStack.Pop(); }, | |
"Did not throw InvalidOperationException when Pop() is called when stack is empty."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment