public Object[][] WarmedDeque()
        {
            LinkedDeque <SimpleLinkedValue> deque = new LinkedDeque <SimpleLinkedValue>();

            WarmUp(deque);
            return(new Object[][] { new Object[] { deque } });
        }
Exemple #2
0
        public void TestLinkedDequeReduceToZero()
        {
            var deque = new LinkedDeque <int>();

            for (var i = 0; i < 100; i++)
            {
                deque.Append(i);
            }
            for (var i = 100; i < 200; i++)
            {
                deque.Prepend(i);
            }
            Assert.False(deque.IsEmpty);
            Assert.Equal(200, deque.Count);

            for (var i = 0; i < 100; i++)
            {
                Assert.Equal(99 - i, deque.Pop());
            }

            for (var i = 0; i < 100; i++)
            {
                Assert.Equal(199 - i, deque.Shift());
            }
            Assert.True(deque.IsEmpty);
            Assert.Equal(0, deque.Count);
        }
        public void descendingIterator_whenWarmed(LinkedDeque <SimpleLinkedValue> deque)
        {
            IList <SimpleLinkedValue> expected = new List <SimpleLinkedValue> ();

            WarmUp(expected);
            IEnumerable <SimpleLinkedValue> expected2 = expected.Reverse();

            Assert.That(elementsEqual(deque.GetDescendingEnumerator(), expected2.GetEnumerator()), Is.True);
        }
        public void iterator_whenWarmed(LinkedDeque <SimpleLinkedValue> deque)
        {
            IList <SimpleLinkedValue> expected = new List <SimpleLinkedValue> ();

            WarmUp(expected);

            // first item from expected has no next or prev
            Assert.That(elementsEqual(((IDeque <SimpleLinkedValue>)deque).GetEnumerator(), expected.GetEnumerator()), Is.True);
        }
        public void peek_whenPopulated(LinkedDeque <SimpleLinkedValue> deque)
        {
            SimpleLinkedValue first = deque.first;

            Assert.That(deque.Peek(), Is.SameAs(first));
            Assert.That(deque.first, Is.SameAs(first));
            Assert.That(deque.Count, Is.EqualTo((int)Capacity()));
            Assert.That(deque.Contains(first), Is.True);
        }
 public void removeElement_toEmpty(LinkedDeque <SimpleLinkedValue> deque)
 {
     while (!deque.IsEmpty)
     {
         SimpleLinkedValue value = deque.Peek();
         Assert.That(deque.Remove(value), Is.True);
         Assert.That(deque.Contains(value), Is.False);
     }
     Assert.That(deque, emptyCollection <SimpleLinkedValue>());
 }
Exemple #7
0
        public void TestLinkedDequeOneItem()
        {
            var deque = new LinkedDeque <int>();

            deque.Append(1);
            Assert.False(deque.IsEmpty);
            foreach (var item in deque)
            {
                Assert.Equal(1, item);
            }
            Assert.Equal(1, deque.First);
            Assert.Equal(1, deque.Last);
            Assert.Equal(1, deque.Pop());
            foreach (var item in deque)
            {
                Assert.True(false);
            }
            Assert.True(deque.IsEmpty);
            Assert.Equal(0, deque.Count);

            deque.Prepend(1);
            Assert.False(deque.IsEmpty);
            foreach (var item in deque)
            {
                Assert.Equal(1, item);
            }
            Assert.Equal(1, deque.First);
            Assert.Equal(1, deque.Last);
            Assert.Equal(1, deque.Shift());
            foreach (var item in deque)
            {
                Assert.True(false);
            }
            Assert.True(deque.IsEmpty);
            Assert.Equal(0, deque.Count);
        }
Exemple #8
0
        public void TestLinkedDequeCollectionOpertions()
        {
            var deque = new LinkedDeque <int>();

            DequeCollectionOperations(deque);
        }
Exemple #9
0
        public void TestLinkedDequeCopyTo()
        {
            var deque = new LinkedDeque <int>();

            DequeCopyTo(deque);
        }
Exemple #10
0
        public void TestLinkedDequeEnumerator()
        {
            var deque = new LinkedDeque <int>();

            DequeEnumerator(deque);
        }
Exemple #11
0
        public void TestLinkedDequePrependAndPop()
        {
            var deque = new LinkedDeque <int>();

            DequePrependAndPop(deque);
        }
Exemple #12
0
        public void TestLinkedDequeExceptions()
        {
            var deque = new LinkedDeque <int>();

            DequeExceptions(deque);
        }
Exemple #13
0
        public void TestLinkedDequeAppendAndShift()
        {
            var deque = new LinkedDeque <int>();

            DequeAppendAndShift(deque);
        }
Exemple #14
0
        public void TestLinkedDequeOperations()
        {
            var deque = new LinkedDeque <string>();

            DequeOperations(deque);
        }
 public void descendingIterator_whenEmpty(LinkedDeque <SimpleLinkedValue> deque)
 {
     Assert.That(deque.GetDescendingEnumerator().MoveNext(), Is.False);
 }
        public void contains_whenNotFound(LinkedDeque <SimpleLinkedValue> deque)
        {
            SimpleLinkedValue unlinked = new SimpleLinkedValue(1);

            Assert.That(deque.Contains(unlinked), Is.False);
        }
Exemple #17
0
        public void TestLinkedDequeConstructor()
        {
            var deque = new LinkedDeque <string>();

            TestDeque(deque);
        }