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

            // Cool behavior
            Assert.IsFalse(arrayStack.GetEnumerator().Current);
        }
예제 #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);
                    }
                }
        }