-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
ToArrayTests.cs
59 lines (52 loc) · 1.82 KB
/
ToArrayTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Xunit;
namespace System.Linq.Parallel.Tests
{
public static class ToArrayTests
{
[Theory]
[InlineData(0)]
[InlineData(1)]
[InlineData(2)]
[InlineData(16)]
public static void ToArray_Unordered(int count)
{
IntegerRangeSet seen = new IntegerRangeSet(0, count);
Assert.All(UnorderedSources.Default(count).ToArray(), x => seen.Add(x));
seen.AssertComplete();
}
[Fact]
[OuterLoop]
public static void ToArray_Unordered_Longrunning()
{
ToArray_Unordered(Sources.OuterLoopCount);
}
[Theory]
[MemberData(nameof(Sources.Ranges), new[] { 0, 1, 2, 16 }, MemberType = typeof(Sources))]
public static void ToArray(Labeled<ParallelQuery<int>> labeled, int count)
{
ParallelQuery<int> query = labeled.Item;
int seen = 0;
Assert.All(query.ToArray(), x => Assert.Equal(seen++, x));
Assert.Equal(count, seen);
}
[Theory]
[OuterLoop]
[MemberData(nameof(Sources.OuterLoopRanges), MemberType = typeof(Sources))]
public static void ToArray_Longrunning(Labeled<ParallelQuery<int>> labeled, int count)
{
ToArray(labeled, count);
}
[Fact]
public static void ToArray_OperationCanceledException_PreCanceled()
{
AssertThrows.AlreadyCanceled(source => source.ToArray());
}
[Fact]
public static void ToArray_ArgumentNullException()
{
AssertExtensions.Throws<ArgumentNullException>("source", () => ((ParallelQuery<bool>)null).ToArray());
}
}
}