public void StackDoesntEnumerateEmpty()
        {
            //Arrange
            var stack    = new StaticStack <string>();
            var expected = false;

            //Act

            foreach (var item in stack)
            {
                expected = true;
            }

            stack.Push("one");
            stack.Push("two");
            stack.Push("three");
            stack.Push("four");
            stack.Clear();

            foreach (var item in stack)
            {
                expected = true;
            }

            //Assert
            Assert.IsFalse(expected);
        }
Exemple #2
0
        public void TestClear_EmptyStack()
        {
            StaticStack <int> stack = new StaticStack <int>();

            stack.Clear();

            Assert.AreEqual(0, stack.Count);
            Assert.AreEqual(string.Empty, stack.ToString());
        }
Exemple #3
0
        public void TestClear_NonEmptyStack()
        {
            StaticStack <int> stack = new StaticStack <int>();
            int stackCount          = 5;

            for (int i = 0; i < stackCount; i++)
            {
                stack.Push(i);
            }

            stack.Clear();

            Assert.AreEqual(0, stack.Count);
            Assert.AreEqual(string.Empty, stack.ToString());
        }
        public void StackClearWorksCorrectly()
        {
            //Arrange
            var stack    = new StaticStack <string>(5);
            int expected = 0;

            //Act
            stack.Push("one");
            stack.Push("two");
            stack.Push("three");
            stack.Push("four");
            stack.Push("five");
            stack.Clear();
            int count = stack.Count;

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