public void ICollectionOptimization() { var source = new NonEnumerableCollection<string> { "hello", "there" }; // If ToList just iterated over the list, this would throw var list = source.ToList(); list.AssertSequenceEqual("hello", "there"); }
public void CountOptimization() { // The counts are different, so we don't need to iterate var first = new NonEnumerableCollection<int> { 1, 2, 3 }; var second = new NonEnumerableCollection<int> { 1, 2 }; Assert.IsFalse(first.SequenceEqual(second)); }
//[Ignore("LINQ to Objects doesn't optimize by count")] public void CountOptimization() { // The counts are different, so we don't need to iterate var first = new NonEnumerableCollection <int> { 1, 2, 3 }; var second = new NonEnumerableCollection <int> { 1, 2 }; Assert.IsFalse(first.SequenceEqual(second)); }
public void OvershootIndexOnCollection() { IEnumerable<int> source = new NonEnumerableCollection<int> { 90, 91, 92 }; Assert.Throws<ArgumentOutOfRangeException>(() => source.ElementAt(3)); }
public void OvershootIndexOnCollection() { IEnumerableWithCount<int> source = new NonEnumerableCollection<int> { 90, 91, 92 }; Assert.AreEqual(0, source.ElementAtOrDefault(3)); }