Esempio n. 1
0
        public static void GroupJoin_CustomComparator(Labeled <ParallelQuery <int> > left, int leftCount, Labeled <ParallelQuery <int> > right, int rightCount)
        {
            ParallelQuery <int> leftQuery  = left.Item;
            ParallelQuery <int> rightQuery = right.Item;
            int seenOuter = 0;

            Assert.All(leftQuery.GroupJoin(rightQuery, x => x, y => y % ElementFactor, (x, y) => KeyValuePair.Create(x, y), new ModularCongruenceComparer(KeyFactor)),
                       p =>
            {
                Assert.Equal(seenOuter++, p.Key);
                if (p.Key % KeyFactor < Math.Min(ElementFactor, rightCount))
                {
                    IntegerRangeSet seenInner = new IntegerRangeSet(0, (rightCount + (ElementFactor - 1) - p.Key % ElementFactor) / ElementFactor);
                    Assert.All(p.Value, y => { Assert.Equal(p.Key % KeyFactor, y % ElementFactor); seenInner.Add(y / ElementFactor); });
                    seenInner.AssertComplete();
                }
                else
                {
                    Assert.Empty(p.Value);
                }
            });
            Assert.Equal(leftCount, seenOuter);
        }
Esempio n. 2
0
 public static void OfType_Unordered_SomeValid_NotPipelined(Labeled<ParallelQuery<int>> labeled, int count)
 {
     ParallelQuery<int> query = labeled.Item;
     IntegerRangeSet seen = new IntegerRangeSet(count / 2, (count + 1) / 2);
     Assert.All(query.Select(x => x >= count / 2 ? (object)x : x.ToString()).OfType<int>().ToList(), x => seen.Add(x));
     seen.AssertComplete();
 }
Esempio n. 3
0
        public static void Distinct_Unordered_NotPipelined(Labeled <ParallelQuery <int> > labeled, int count)
        {
            ParallelQuery <int> query = labeled.Item;
            IntegerRangeSet     seen  = new IntegerRangeSet(0, count);

            Assert.All(query.Distinct(new ModularCongruenceComparer(count)).ToList(), x => seen.Add(x % count));
            seen.AssertComplete();
        }
Esempio n. 4
0
        public static void Except_Unordered_Distinct_NotPipelined(Labeled <ParallelQuery <int> > left, int leftCount, Labeled <ParallelQuery <int> > right, int rightCount, int start, int count)
        {
            ParallelQuery <int> leftQuery  = left.Item;
            ParallelQuery <int> rightQuery = right.Item;

            leftCount  = Math.Min(DuplicateFactor * 2, leftCount);
            rightCount = Math.Min(DuplicateFactor, (rightCount + 1) / 2);
            int             expectedCount = Math.Max(0, leftCount - rightCount);
            IntegerRangeSet seen          = new IntegerRangeSet(leftCount - expectedCount, expectedCount);

            Assert.All(leftQuery.Except(rightQuery.Select(x => Math.Abs(x) % DuplicateFactor),
                                        new ModularCongruenceComparer(DuplicateFactor * 2)).ToList(), x => seen.Add(x % (DuplicateFactor * 2)));
            seen.AssertComplete();
        }
Esempio n. 5
0
        public static void GroupBy_Unordered_ElementSelector_ResultSelector(Labeled <ParallelQuery <int> > labeled, int count)
        {
            ParallelQuery <int> query      = labeled.Item;
            IntegerRangeSet     groupsSeen = new IntegerRangeSet(0, Math.Min(count, GroupFactor));

            foreach (var group in query.GroupBy(x => x % GroupFactor, x => - x, (key, elements) => KeyValuePair.Create(key, elements)))
            {
                groupsSeen.Add(group.Key);
                int             expected     = 1 + (count - (group.Key + 1)) / GroupFactor;
                IntegerRangeSet elementsSeen = new IntegerRangeSet(1 - expected, expected);
                Assert.All(group.Value, x => { Assert.Equal(group.Key, -x % GroupFactor); elementsSeen.Add(x / GroupFactor); });
                elementsSeen.AssertComplete();
            }
            groupsSeen.AssertComplete();
        }
Esempio n. 6
0
        public static void GroupBy_Unordered_ResultSelector_CustomComparator(Labeled <ParallelQuery <int> > labeled, int count)
        {
            ParallelQuery <int> query      = labeled.Item;
            IntegerRangeSet     groupsSeen = new IntegerRangeSet(0, Math.Min(count, GroupFactor));

            foreach (var group in query.GroupBy(x => x, (key, elements) => KeyValuePair.Create(key, elements), new ModularCongruenceComparer(GroupFactor)))
            {
                groupsSeen.Add(group.Key % GroupFactor);
                IntegerRangeSet elementsSeen = new IntegerRangeSet(0, 1 + (count - (group.Key % GroupFactor + 1)) / GroupFactor);
                Assert.All(group.Value, x => { Assert.Equal(group.Key % GroupFactor, x % GroupFactor); elementsSeen.Add(x / GroupFactor); });
                elementsSeen.AssertComplete();
            }
            groupsSeen.AssertComplete();
        }