Ejemplo n.º 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>()));
        }
Ejemplo n.º 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>()));
        }
Ejemplo n.º 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>()));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 8
0
 public void SingleOrFallbackWithSingleElementSequence()
 {
     Assert.AreEqual(10, new[] { 10 }.Select(x => x).SingleOrFallback(BreakingFunc.Of <int>()));
 }
Ejemplo n.º 9
0
 public void SingleOrFallbackWithSingleElementSequenceIListOptimized()
 {
     Assert.AreEqual(10, new[] { 10 }.SingleOrFallback(BreakingFunc.Of <int>()));
 }
Ejemplo n.º 10
0
 public void ZipWithNullFirstSequence()
 {
     MoreEnumerable.EquiZip(null, new[] { 4, 5, 6 }, BreakingFunc.Of <int, int, int>());
 }
Ejemplo n.º 11
0
 public void SingleOrFallbackWithNullSequence()
 {
     MoreEnumerable.SingleOrFallback(null, BreakingFunc.Of <int>());
 }
Ejemplo n.º 12
0
 public void IsLazy()
 {
     new BreakingSequence <object>()
     .CountDown(42, BreakingFunc.Of <object, int?, object>());
 }
Ejemplo n.º 13
0
 public void ZipWithNullSecondSequence()
 {
     new[] { 1, 2, 3 }.EquiZip(null, BreakingFunc.Of <int, int, int>());
 }
Ejemplo n.º 14
0
        public void ZipShortestIsLazy()
        {
            var bs = new BreakingSequence <int>();

            bs.ZipShortest(bs, BreakingFunc.Of <int, int, int>());
        }
Ejemplo n.º 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>());
 }
Ejemplo n.º 16
0
 public void MinByIsLazy()
 {
     new BreakingSequence <int>().MinBy(BreakingFunc.Of <int, int>());
 }
Ejemplo n.º 17
0
 public void PartialSortByIsLazy()
 {
     new BreakingSequence <object>().PartialSortBy(1, BreakingFunc.Of <object, object>());
 }
Ejemplo n.º 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>());
 }
Ejemplo n.º 19
0
 public void FlattenPredicateIsLazy()
 {
     new BreakingSequence <int>().Flatten(BreakingFunc.Of <object, bool>());
 }
Ejemplo n.º 20
0
 public void TagFirstLastIsLazy()
 {
     new BreakingSequence <object>().TagFirstLast(BreakingFunc.Of <object, bool, bool, object>());
 }
Ejemplo n.º 21
0
 public void SingleOrFallbackWithLongSequence()
 {
     new[] { 10, 20, 30 }.Select(x => x).SingleOrFallback(BreakingFunc.Of <int>());
 }
Ejemplo n.º 22
0
 public void ScanRightSeedIsLazy()
 {
     new BreakingSequence<int>().ScanRight(string.Empty, BreakingFunc.Of<int, string, string>());
 }
Ejemplo n.º 23
0
 public void SingleOrFallbackWithLongSequenceIListOptimized()
 {
     new[] { 10, 20, 30 }.SingleOrFallback(BreakingFunc.Of <int>());
 }
Ejemplo n.º 24
0
        public void ZipIsLazy()
        {
            var bs = new BreakingSequence <int>();

            bs.EquiZip(bs, BreakingFunc.Of <int, int, int>());
        }
Ejemplo n.º 25
0
 public void ScanRightIsLazy()
 {
     new BreakingSequence<int>().ScanRight(BreakingFunc.Of<int, int, int>());
 }
Ejemplo n.º 26
0
 public void FoldWithTooManyItems()
 {
     Assert.Throws <InvalidOperationException>(() =>
                                               Enumerable.Range(1, 3).Fold(BreakingFunc.Of <int, int, int>()));
 }
Ejemplo n.º 27
0
 public void SingleOrFallbackWithLongSequenceIListOptimized()
 {
     Assert.Throws <InvalidOperationException>(() =>
                                               new[] { 10, 20, 30 }.SingleOrFallback(BreakingFunc.Of <int>()));
 }
Ejemplo n.º 28
0
 public void ZipShortestWithNullSecondSequence()
 {
     Assert.ThrowsArgumentNullException("second", () =>
                                        new[] { 1, 2, 3 }.ZipShortest(null, BreakingFunc.Of <int, int, int>()));
 }
Ejemplo n.º 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>()));
        }
Ejemplo n.º 30
0
 public void ZipShortestWithNullFirstSequence()
 {
     Assert.ThrowsArgumentNullException("first", () =>
                                        MoreEnumerable.ZipShortest(null, new[] { 4, 5, 6 }, BreakingFunc.Of <int, int, int>()));
 }