예제 #1
0
        public void Push_MoreThanFiveElements_ShouldBeReturnedWhenPop()
        {
            var arrayStack = new ArrayStack <bool>();

            arrayStack.Push(true);
            arrayStack.Push(true);
            arrayStack.Push(true);
            arrayStack.Push(true);
            arrayStack.Push(true);

            Assert.AreEqual(true, arrayStack.Pop());
            Assert.AreEqual(true, arrayStack.Pop());
            Assert.AreEqual(true, arrayStack.Pop());
            Assert.AreEqual(true, arrayStack.Pop());
            Assert.AreEqual(true, arrayStack.Pop());
        }
예제 #2
0
        public void Push_MoreThanFiveElements_ShouldEnumeratorWork()
        {
            var arrayStack = new ArrayStack <bool>();

            arrayStack.Push(true);
            arrayStack.Push(true);
            arrayStack.Push(true);
            arrayStack.Push(true);
            arrayStack.Push(true);

            using (var actualEnumerator = arrayStack.GetEnumerator())
                using (var expectedEnumerator = new List <bool> {
                    true, true, true, true, true
                }.GetEnumerator())
                {
                    while (actualEnumerator.MoveNext() && expectedEnumerator.MoveNext())
                    {
                        Assert.AreEqual(actualEnumerator.Current, expectedEnumerator.Current);
                    }
                }
        }
예제 #3
0
        public void Pop_EmptyStack_ThrowsException()
        {
            var arrayStack = new ArrayStack <bool>();

            Assert.Throws <IndexOutOfRangeException>(() => arrayStack.Top());
        }