Ejemplo n.º 1
0
        public void PeekEnumerator_ShouldWorkForEmptyEnumerator()
        {
            var data       = new int [0];
            var enumerator = new PeekEnumerator <int>(data);

            Assert.IsFalse(enumerator.TryPeek(out _));
            Assert.IsFalse(enumerator.MoveNext());
            Assert.IsFalse(enumerator.TryPeek(out _));
        }
Ejemplo n.º 2
0
        public void PeekEnumerator_ShouldWorkForOneElement()
        {
            var data       = new int[] { 1 };
            var enumerator = new PeekEnumerator <int>(data);

            Assert.IsTrue(enumerator.TryPeek(out var first));
            Assert.AreEqual(1, first);


            Assert.IsTrue(enumerator.MoveNext());
            Assert.AreEqual(1, enumerator.Current);

            Assert.IsFalse(enumerator.TryPeek(out _));
            Assert.IsFalse(enumerator.MoveNext());
        }