Ejemplo n.º 1
0
        /// <summary>
        /// For checking that exception was throwing when MoveNext was called
        /// </summary>
        /// <param name="deferredFunction"></param>
        /// <typeparam name="T"></typeparam>
        internal static void AssertDeferred <T>(
            Func <IEnumerable <int>, IEnumerable <T> > deferredFunction)
        {
            ThrowingEnumerable source = new ThrowingEnumerable();
            var result = deferredFunction(source);

            using (var iterator = result.GetEnumerator())
            {
                Assert.Throws <InvalidOperationException>(() => iterator.MoveNext());
            }
        }
Ejemplo n.º 2
0
 public void Execution_Is_Deferred_With_Index()
 {
     ThrowingEnumerable.AssertDeferred(src => src.Where((x, index) => x > 0));
 }
Ejemplo n.º 3
0
 public void Execution_Is_Deferred()
 {
     ThrowingEnumerable.AssertDeferred(src => src.Where(x => x > 0));
 }