Beispiel #1
0
        public void MoveAfterEnd_Int32()
        {
            IEnumerable <int> list =
                //new List<int>(new int[] { });
                new CachedList <int>(new int[] { });

            IEnumerator <int> e = list.GetEnumerator();

            Assert.AreEqual(0, e.Current, "Before MoveNext.");
            e.MoveNext();
            Assert.AreEqual(0, e.Current, "After one MoveNext.");
            e.MoveNext();
            Assert.AreEqual(0, e.Current, "After two MoveNext's.");
        }
Beispiel #2
0
        public void MoveAfterEnd_String()
        {
            IEnumerable <string> list =
                //new List<string>(new string[] { });
                new CachedList <string>(new string[] { });

            IEnumerator <string> e = list.GetEnumerator();

            Assert.AreEqual(null, e.Current, "Before MoveNext.");
            e.MoveNext();
            Assert.AreEqual(null, e.Current, "After one MoveNext.");
            e.MoveNext();
            Assert.AreEqual(null, e.Current, "After two MoveNext's.");
        }
Beispiel #3
0
        public void Indexer()
        {
            CachedList <string> cachedList = new CachedList <string>(threeLetterStrings);

            for (int i = 0; i < threeLetterStrings.Length; i++)
            {
                Assert.AreEqual(threeLetterStrings[i], cachedList[i], "First/at index: " + i.ToString());
            }

            // move past the end
            IEnumerator <string> cachedListEnum = cachedList.GetEnumerator();

            for (int i = 0; i < threeLetterStrings.Length + 1; i++)
            {
                cachedListEnum.MoveNext();
            }

            for (int i = 0; i < threeLetterStrings.Length; i++)
            {
                Assert.AreEqual(threeLetterStrings[i], cachedList[i], "Second/at index: " + i.ToString());
            }
        }