public void DoesNotRequireEnumerationOfEitherInput() { IEnumerableWithCount<int> first = new ThrowingEnumerable(7); IEnumerableWithCount<int> second = new ThrowingEnumerable(10); IEnumerableWithCount<int> result = first.Concat(second); Assert.AreEqual(17, result.Count); }
public void FirstSequenceIsNotAccessedBeforeFirstUse() { var first = new ThrowingEnumerable(); var query = first.Concat(new[] { 1, 2, 3 }); using (var iterator = query.GetEnumerator()) { Assert.Throws(typeof(InvalidOperationException), () => iterator.MoveNext()); } }
public void FirstSequenceIsntAccessedBeforeFirstUse() { IEnumerableWithCount<int> first = new ThrowingEnumerable(0); IEnumerableWithCount<int> second = new int[] { 5 }.AsEnumerableWithCount(); // No exception yet... var query = first.Concat(second); // Still no exception... using (var iterator = query.GetEnumerator()) { // Now it will go bang Assert.Throws<InvalidOperationException>(() => iterator.MoveNext()); } }
public void FirstSequenceIsntAccessedBeforeFirstUse() { IEnumerable <int> first = new ThrowingEnumerable(); IEnumerable <int> second = new int[] { 5 }; // No exception yet... var query = first.Concat(second); // Still no exception... using (var iterator = query.GetEnumerator()) { // Now it will go bang Assert.Throws <InvalidOperationException>(() => iterator.MoveNext()); } }