Example #1
0
        public static void CanAggregateLettersUsingChunkWhile()
        {
            var nums =
                new SeriesBuilder<int, char>
                    { {0, 'a'}, {10, 'b'}, {11, 'c'} }.Series;

            var actual =
                nums.Aggregate(Aggregation.ChunkWhile<int>((k1, k2) => k2 - k1 < 10),
                    segment => segment.Data.Keys.First(),
                    segment => new OptionalValue<string>(new string(segment.Data.Values.ToArray())));

            var expected =
                new SeriesBuilder<int, string> {
                    { 0,  "a" },
                    { 10, "bc" }}.Series;

            Assert.AreEqual(expected, actual);
        }
Example #2
0
        public static void CanAggregateLettersUsingChunkWhile()
        {
            var nums =
                new SeriesBuilder <int, char>
            {
                { 0, 'a' }, { 10, 'b' }, { 11, 'c' }
            }.Series;

            var actual =
                nums.Aggregate(Aggregation.ChunkWhile <int>((k1, k2) => k2 - k1 < 10),
                               segment => segment.Data.Keys.First(),
                               segment => new string(segment.Data.Values.ToArray()));

            var expected =
                new SeriesBuilder <int, string> {
                { 0, "a" },
                { 10, "bc" }
            }.Series;

            Assert.AreEqual(expected, actual);
        }