Пример #1
0
        public void RightJoinWithHomogeneousSequencesIsLazy()
        {
            var xs = new BreakingSequence <int>();
            var ys = new BreakingSequence <int>();

            Assert.DoesNotThrow(() =>
                                xs.RightJoin(ys, e => e,
                                             BreakingFunc.Of <int, object>(),
                                             BreakingFunc.Of <int, int, object>()));
        }
Пример #2
0
        public void RightJoinIsLazy()
        {
            var xs = new BreakingSequence <int>();
            var ys = new BreakingSequence <object>();

            Assert.DoesNotThrow(() =>
                                xs.RightJoin(ys, x => x.GetHashCode(), y => y,
                                             BreakingFunc.Of <object, object>(),
                                             BreakingFunc.Of <int, object, object>()));
        }
Пример #3
0
        public void ToArrayByIndexWithBadIndexSelectorThrows()
        {
            var input = new[] { 42 };

            Assert.Throws <IndexOutOfRangeException>(() =>
                                                     input.ToArrayByIndex(_ => - 1));

            Assert.Throws <IndexOutOfRangeException>(() =>
                                                     input.ToArrayByIndex(_ => - 1, BreakingFunc.Of <int, object>()));
        }
Пример #4
0
        public void LeftJoinWithHomogeneousSequencesWithComparerIsLazy()
        {
            var xs = new BreakingSequence <int>();
            var ys = new BreakingSequence <int>();

            Assert.DoesNotThrow(() =>
                                xs.LeftJoin(ys, e => e,
                                            BreakingFunc.Of <int, object>(),
                                            BreakingFunc.Of <int, int, object>(),
                                            comparer: null));
        }
Пример #5
0
        public void TestSegmentationStartsWithSecondItem()
        {
            var sequence = new[] { 0 };
            var resultA  = sequence.Segment(BreakingFunc.Of <int, bool>());
            var resultB  = sequence.Segment(BreakingFunc.Of <int, int, bool>());
            var resultC  = sequence.Segment(BreakingFunc.Of <int, int, int, bool>());

            Assert.IsTrue(resultA.Any());
            Assert.IsTrue(resultB.Any());
            Assert.IsTrue(resultC.Any());
        }
Пример #6
0
        public void LeftJoinWithComparerIsLazy()
        {
            var xs = new BreakingSequence <int>();
            var ys = new BreakingSequence <object>();

            Assert.DoesNotThrow(() =>
                                xs.LeftJoin(ys, x => x, y => y.GetHashCode(),
                                            BreakingFunc.Of <int, object>(),
                                            BreakingFunc.Of <int, object, object>(),
                                            comparer: null));
        }
Пример #7
0
        public void GroupAdjacentIsLazy()
        {
            var bs  = new BreakingSequence <object>();
            var bf  = BreakingFunc.Of <object, int>();
            var bfo = BreakingFunc.Of <object, object>();
            var bfg = BreakingFunc.Of <int, IEnumerable <object>, IEnumerable <object> >();

            bs.GroupAdjacent(bf);
            bs.GroupAdjacent(bf, bfo);
            bs.GroupAdjacent(bf, bfo, EqualityComparer <int> .Default);
            bs.GroupAdjacent(bf, EqualityComparer <int> .Default);
            bs.GroupAdjacent(bf, bfg);
            bs.GroupAdjacent(bf, bfg, EqualityComparer <int> .Default);
        }
Пример #8
0
 public void SingleOrFallbackWithSingleElementSequence()
 {
     Assert.AreEqual(10, new[] { 10 }.Select(x => x).SingleOrFallback(BreakingFunc.Of <int>()));
 }
Пример #9
0
 public void SingleOrFallbackWithSingleElementSequenceIListOptimized()
 {
     Assert.AreEqual(10, new[] { 10 }.SingleOrFallback(BreakingFunc.Of <int>()));
 }
Пример #10
0
 public void ZipWithNullFirstSequence()
 {
     MoreEnumerable.EquiZip(null, new[] { 4, 5, 6 }, BreakingFunc.Of <int, int, int>());
 }
Пример #11
0
 public void SingleOrFallbackWithNullSequence()
 {
     MoreEnumerable.SingleOrFallback(null, BreakingFunc.Of <int>());
 }
Пример #12
0
 public void IsLazy()
 {
     new BreakingSequence <object>()
     .CountDown(42, BreakingFunc.Of <object, int?, object>());
 }
Пример #13
0
 public void ZipWithNullSecondSequence()
 {
     new[] { 1, 2, 3 }.EquiZip(null, BreakingFunc.Of <int, int, int>());
 }
Пример #14
0
        public void ZipShortestIsLazy()
        {
            var bs = new BreakingSequence <int>();

            bs.ZipShortest(bs, BreakingFunc.Of <int, int, int>());
        }
Пример #15
0
 public void TestSegmentIsLazy()
 {
     new BreakingSequence <int>().Segment(BreakingFunc.Of <int, bool>());
     new BreakingSequence <int>().Segment(BreakingFunc.Of <int, int, bool>());
     new BreakingSequence <int>().Segment(BreakingFunc.Of <int, int, int, bool>());
 }
Пример #16
0
 public void MinByIsLazy()
 {
     new BreakingSequence <int>().MinBy(BreakingFunc.Of <int, int>());
 }
Пример #17
0
 public void PartialSortByIsLazy()
 {
     new BreakingSequence <object>().PartialSortBy(1, BreakingFunc.Of <object, object>());
 }
Пример #18
0
 public void TestLeadIsLazy()
 {
     new BreakingSequence <int>().Lead(5, BreakingFunc.Of <int, int, int>());
     new BreakingSequence <int>().Lead(5, -1, BreakingFunc.Of <int, int, int>());
 }
Пример #19
0
 public void FlattenPredicateIsLazy()
 {
     new BreakingSequence <int>().Flatten(BreakingFunc.Of <object, bool>());
 }
Пример #20
0
 public void TagFirstLastIsLazy()
 {
     new BreakingSequence <object>().TagFirstLast(BreakingFunc.Of <object, bool, bool, object>());
 }
Пример #21
0
 public void SingleOrFallbackWithLongSequence()
 {
     new[] { 10, 20, 30 }.Select(x => x).SingleOrFallback(BreakingFunc.Of <int>());
 }
Пример #22
0
 public void ScanRightSeedIsLazy()
 {
     new BreakingSequence<int>().ScanRight(string.Empty, BreakingFunc.Of<int, string, string>());
 }
Пример #23
0
 public void SingleOrFallbackWithLongSequenceIListOptimized()
 {
     new[] { 10, 20, 30 }.SingleOrFallback(BreakingFunc.Of <int>());
 }
Пример #24
0
        public void ZipIsLazy()
        {
            var bs = new BreakingSequence <int>();

            bs.EquiZip(bs, BreakingFunc.Of <int, int, int>());
        }
Пример #25
0
 public void ScanRightIsLazy()
 {
     new BreakingSequence<int>().ScanRight(BreakingFunc.Of<int, int, int>());
 }
Пример #26
0
 public void FoldWithTooManyItems()
 {
     Assert.Throws <InvalidOperationException>(() =>
                                               Enumerable.Range(1, 3).Fold(BreakingFunc.Of <int, int, int>()));
 }
Пример #27
0
 public void SingleOrFallbackWithLongSequenceIListOptimized()
 {
     Assert.Throws <InvalidOperationException>(() =>
                                               new[] { 10, 20, 30 }.SingleOrFallback(BreakingFunc.Of <int>()));
 }
Пример #28
0
 public void ZipShortestWithNullSecondSequence()
 {
     Assert.ThrowsArgumentNullException("second", () =>
                                        new[] { 1, 2, 3 }.ZipShortest(null, BreakingFunc.Of <int, int, int>()));
 }
Пример #29
0
        public void ToArrayByIndexWithLengthWithBadIndexSelectorThrows(int length, int badIndex)
        {
            var input = new[] { 42 };

            Assert.Throws <IndexOutOfRangeException>(() =>
                                                     input.ToArrayByIndex(length, _ => badIndex));

            Assert.Throws <IndexOutOfRangeException>(() =>
                                                     input.ToArrayByIndex(10, _ => - 1, BreakingFunc.Of <int, object>()));
        }
Пример #30
0
 public void ZipShortestWithNullFirstSequence()
 {
     Assert.ThrowsArgumentNullException("first", () =>
                                        MoreEnumerable.ZipShortest(null, new[] { 4, 5, 6 }, BreakingFunc.Of <int, int, int>()));
 }