/// <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()); } }
public void Execution_Is_Deferred_With_Index() { ThrowingEnumerable.AssertDeferred(src => src.Where((x, index) => x > 0)); }
public void Execution_Is_Deferred() { ThrowingEnumerable.AssertDeferred(src => src.Where(x => x > 0)); }