Exemplo n.º 1
0
        public void MergeByOrderedByLastItemIsLargest()
        {
            const int expectedLast = 43;

            var a = new MergeByTestItem[]
            {
                new MergeByTestItem {
                    Id = 1
                },
                new MergeByTestItem {
                    Id = 8
                },
                new MergeByTestItem {
                    Id = 13
                },
                new MergeByTestItem {
                    Id = 19
                },
                new MergeByTestItem {
                    Id = 40
                },
            };
            var b = new MergeByTestItem[]
            {
                new MergeByTestItem {
                    Id = 0
                },
                new MergeByTestItem {
                    Id = 4
                },
                new MergeByTestItem {
                    Id = 12
                },
                new MergeByTestItem {
                    Id = 41
                }
            };
            var c = new MergeByTestItem[]
            {
                new MergeByTestItem {
                    Id = 3
                },
                new MergeByTestItem {
                    Id = 22
                },
                new MergeByTestItem {
                    Id = 30
                },
                new MergeByTestItem {
                    Id = 37
                },
                new MergeByTestItem {
                    Id = 43
                },
            };
            var combined = new MergeByTestItem[][] { a, b, c };

            var mergeOrdered = combined.MergeOrderedBy(m => m.Id);

            Assert.AreEqual(expectedLast, mergeOrdered.Last().Id);
        }
Exemplo n.º 2
0
        public void MergeByOrderedByCombinesSequences()
        {
            const int expectedCount = 14;

            var a = new MergeByTestItem[]
            {
                new MergeByTestItem {
                    Id = 1
                },
                new MergeByTestItem {
                    Id = 8
                },
                new MergeByTestItem {
                    Id = 13
                },
                new MergeByTestItem {
                    Id = 19
                },
                new MergeByTestItem {
                    Id = 40
                },
            };
            var b = new MergeByTestItem[]
            {
                new MergeByTestItem {
                    Id = 0
                },
                new MergeByTestItem {
                    Id = 4
                },
                new MergeByTestItem {
                    Id = 12
                },
                new MergeByTestItem {
                    Id = 41
                }
            };
            var c = new MergeByTestItem[]
            {
                new MergeByTestItem {
                    Id = 3
                },
                new MergeByTestItem {
                    Id = 22
                },
                new MergeByTestItem {
                    Id = 30
                },
                new MergeByTestItem {
                    Id = 37
                },
                new MergeByTestItem {
                    Id = 43
                },
            };
            var combined = new MergeByTestItem[][] { a, b, c };

            var mergeOrdered = combined.MergeOrderedBy(m => m.Id);

            Assert.AreEqual(expectedCount, mergeOrdered.Count());
        }