Exemple #1
0
        public void MyStack_3_Top_1_ThrowsExceptionOnEmptyStack()
        {
            // Arrange
            IMyStack <string> stack = DSBuilder.CreateMyStack();

            // Act & Assert
            Assert.Throws(typeof(MyStackEmptyException), () => stack.Top());
        }
Exemple #2
0
        public void MyStack_2_Push_2_TopIsOkAfter1Push()
        {
            // Arrange
            IMyStack <string> stack    = DSBuilder.CreateMyStack();
            string            expected = "a";

            // Act
            stack.Push("a");
            string actual = stack.Top();

            // Assert
            Assert.AreEqual(expected, actual);
        }
        public void MyStack_2_Push_2_TopIsOkAfter1Push()
        {
            // Arrange
            IMyStack <int> stack    = DSBuilder.CreateMyArrayListStack();
            int            expected = 1;

            // Act
            stack.Push(1);
            int actual = stack.Top();

            // Assert
            Assert.AreEqual(expected, actual);
        }
Exemple #4
0
        public void MyStack_3_Top_2_IsEmptyReturnsFalseAfterTopOnOneElement()
        {
            // Arrange
            IMyStack <string> stack = DSBuilder.CreateMyStack();
            bool expected           = false;

            // Act
            stack.Push("a");
            stack.Top();
            bool actual = stack.IsEmpty();

            // Assert
            Assert.AreEqual(expected, actual);
        }