コード例 #1
0
ファイル: ToListTest.cs プロジェクト: CoderDennis/vbLINQ
 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
ファイル: SequenceEqualTest.cs プロジェクト: mafm/edulinq
 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
ファイル: ElementAtTest.cs プロジェクト: mafm/edulinq
 public void OvershootIndexOnCollection()
 {
     IEnumerable<int> source = new NonEnumerableCollection<int> { 90, 91, 92 };
     Assert.Throws<ArgumentOutOfRangeException>(() => source.ElementAt(3));
 }
コード例 #5
0
 public void OvershootIndexOnCollection()
 {
     IEnumerableWithCount<int> source = new NonEnumerableCollection<int> { 90, 91, 92 };
     Assert.AreEqual(0, source.ElementAtOrDefault(3));
 }