Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit ca16c3d

Browse files
Fix #2345 , split test for non-throwing base enumerable.
1 parent 4b55804 commit ca16c3d

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/System.Linq.Parallel/tests/ExchangeTests.cs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Collections.Concurrent;
66
using System.Collections.Generic;
77
using System.Linq;
8+
using System.Threading;
89
using Xunit;
910

1011
namespace Test
@@ -131,22 +132,26 @@ public static void Merge_Ordered_Longrunning(Labeled<ParallelQuery<int>> labeled
131132
}
132133

133134
[Theory]
134-
[MemberData("MergeData", (object)(new int[] { 16, 1024 }))]
135-
[MemberData("ThrowOnCount_AllMergeOptions_MemberData", (object)(new int[] { 16, 1024 }))]
135+
[MemberData("ThrowOnCount_AllMergeOptions_MemberData", (object)(new int[] { 4, 8 }))]
136136
// FailingMergeData has enumerables that throw errors when attempting to perform the nth enumeration.
137137
// This test checks whether the query runs in a pipelined or buffered fashion.
138138
public static void Merge_Ordered_Pipelining(Labeled<ParallelQuery<int>> labeled, int count, ParallelMergeOptions options)
139139
{
140-
Assert.Equal(0, labeled.Item.WithMergeOptions(options).Select(x => x).First());
140+
Assert.Equal(0, labeled.Item.WithDegreeOfParallelism(count - 1).WithMergeOptions(options).First());
141141
}
142142

143143
[Theory]
144-
[OuterLoop]
145-
[MemberData("MergeData", (object)(new int[] { 1024 * 4, 1024 * 1024 }))]
146-
[MemberData("ThrowOnCount_AllMergeOptions_MemberData", (object)(new int[] { 1024 * 4, 1024 * 1024 }))]
147-
public static void Merge_Ordered_Pipelining_Longrunning(Labeled<ParallelQuery<int>> labeled, int count, ParallelMergeOptions options)
144+
[MemberData("MergeData", (object)(new int[] { 4, 8 }))]
145+
// This test checks whether the query runs in a pipelined or buffered fashion.
146+
public static void Merge_Ordered_Pipelining_Select(Labeled<ParallelQuery<int>> labeled, int count, ParallelMergeOptions options)
148147
{
149-
Merge_Ordered_Pipelining(labeled, count, options);
148+
int countdown = count;
149+
Func<int, int> down = i =>
150+
{
151+
if (Interlocked.Decrement(ref countdown) == 0) throw new DeliberateTestException();
152+
return i;
153+
};
154+
Assert.Equal(0, labeled.Item.WithDegreeOfParallelism(count - 1).WithMergeOptions(options).Select(down).First());
150155
}
151156

152157
[Theory]

0 commit comments

Comments
 (0)