示例#1
0
        public void GetEnumerator_RefType()
        {
            var list = new LightweightList <string>();

            list.AddRange(Enumerable.Range(0, 10).Select(x => x.ToString()).ToArray());

            var enumerator = list.GetEnumerator();

            Assert.Null(enumerator.Current);

            int count = 0;

            for (; enumerator.MoveNext(); count++)
            {
                Assert.Equal(count.ToString(), enumerator.Current);
            }

            Assert.Equal(10, count);
            Assert.Null(enumerator.Current);
        }
示例#2
0
        public void GetEnumerator()
        {
            var list = new LightweightList <int>();

            list.AddRange(Enumerable.Range(0, 10).ToArray());

            var enumerator = list.GetEnumerator();

            Assert.Equal(0, enumerator.Current);

            int count = 0;

            for (; enumerator.MoveNext(); count++)
            {
                Assert.Equal(count, enumerator.Current);
            }

            Assert.Equal(10, count);
            Assert.Equal(0, enumerator.Current);
        }