-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathDuplicatesTest.cs
60 lines (54 loc) · 1.53 KB
/
DuplicatesTest.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
60
namespace Test.Async;
public sealed class DuplicatesTest
{
[Fact]
public void DuplicatesIsLazy()
{
_ = new AsyncBreakingSequence<int>().Duplicates();
}
[Theory]
[InlineData(new int[] { 1, 2, 3 }, new int[] { })]
[InlineData(new int[] { 1, 2, 1, 3, 1, 2, 1 }, new int[] { 1, 2 })]
[InlineData(new int[] { 3, 3, 2, 2, 1, 1 }, new int[] { 3, 2, 1 })]
public async Task DuplicatesBehavior(IEnumerable<int> source, IEnumerable<int> expected)
{
await using var ts = source.AsTestingSequence();
var result = ts.Duplicates();
await result.AssertSequenceEqual(expected);
}
public static IEnumerable<object[]> GetStringParameters()
{
yield return new object[]
{
new string[] { "foo", "bar", "qux" },
StringComparer.Ordinal,
Array.Empty<string>(),
};
yield return new object[]
{
new string[] { "foo", "FOO", "bar", "qux" },
StringComparer.Ordinal,
Array.Empty<string>(),
};
yield return new object[]
{
new string[] { "foo", "FOO", "bar", "qux" },
StringComparer.OrdinalIgnoreCase,
new string[] { "FOO" },
};
yield return new object[]
{
new string[] { "Bar", "foo", "FOO", "bar", "qux" },
StringComparer.OrdinalIgnoreCase,
new string[] { "FOO", "bar" },
};
}
[Theory]
[MemberData(nameof(GetStringParameters))]
public async Task DuplicatesComparerBehavior(IEnumerable<string> source, StringComparer comparer, IEnumerable<string> expected)
{
await using var ts = source.AsTestingSequence();
var result = ts.Duplicates(comparer);
await result.AssertSequenceEqual(expected);
}
}