private IEnumerable <string> BuildEnumerableWithSmartnumerator(IEnumerable <string> sourceEnumerable)
        {
            target = new Smartnumerator <string>(sourceEnumerable.GetEnumerator());
            var fake = new Mock <IEnumerable <string> >();

            fake.Setup(x => x.GetEnumerator()).Returns(target);

            return(fake.Object);
        }
Beispiel #2
0
        public void GetEnumerator_Must_ReturnTheProvidedEnumerator()
        {
            var snumerator = new Smartnumerator <string>(
                new Mock <IEnumerator <string> >().Object);

            target = new Smartnumerable <string>(snumerator);

            var enumerator = target.GetEnumerator();

            Assert.AreEqual(snumerator, enumerator);
        }
Beispiel #3
0
        public void GetEnumerator_SubsequentInvocations_Must_ReturnTheSameProvidedEnumerator(
            int subsequentInvocationCount)
        {
            var snumerator = new Smartnumerator <string>(
                new Mock <IEnumerator <string> >().Object);

            target = new Smartnumerable <string>(snumerator);

            target.GetEnumerator();

            for (int i = 2; i < subsequentInvocationCount + 2; i++)
            {
                Assert.AreEqual(snumerator, target.GetEnumerator(), $"invocation #{i}");
            }
        }
 public Smartnumerable(Smartnumerator <TValue> enumerator)
 {
     this.enumerator = enumerator;
 }