// Check that some queries run in parallel by default, and some require forcing. public static void WithExecutionMode(Labeled <ParallelQuery <int> > labeled, int count, Labeled <Action <ParVerifier, ParallelQuery <int> > > operation, ParallelExecutionMode mode) { ParVerifier verifier = new ParVerifier(); operation.Item(verifier, labeled.Item.WithExecutionMode(mode)); verifier.AssertPassed(); }
[MemberData("WithExecutionModeQueryData", new int[] { 1, 4 })] // DOP of 1 to verify sequential and 4 to verify parallel public static void WithExecutionMode( Labeled <ParallelQuery <int> > labeled, int requestedDop, int expectedDop, Labeled <Action <UsedTaskTracker, ParallelQuery <int> > > operation, ParallelExecutionMode mode) { UsedTaskTracker tracker = new UsedTaskTracker(); operation.Item(tracker, labeled.Item.WithDegreeOfParallelism(requestedDop).WithExecutionMode(mode)); Assert.Equal(expectedDop, tracker.UniqueTasksCount); }