Пример #1
0
 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");
 }
Пример #2
0
 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));
 }
Пример #3
0
        //[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));
        }
Пример #4
0
 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));
 }