-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathV3BinaryCompatibilityTests.cs
More file actions
47 lines (43 loc) · 2.46 KB
/
Copy pathV3BinaryCompatibilityTests.cs
File metadata and controls
47 lines (43 loc) · 2.46 KB
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using EnumerableAsyncProcessor.Builders;
using EnumerableAsyncProcessor.Extensions;
namespace EnumerableAsyncProcessor.UnitTests;
/// <summary>
/// TUnit.Engine (the framework running this suite) is itself compiled against
/// EnumerableAsyncProcessor, and the locally built assembly shadows the version TUnit shipped
/// with because the assembly identity matches. If a member TUnit.Engine binds to disappears,
/// test DISCOVERY crashes with MissingMethodException before any test runs. These are the
/// exact signatures TUnit.Engine references - keep them until TUnit rebuilds against v4.
/// </summary>
public class V3BinaryCompatibilityTests
{
[Test]
public async Task Members_Bound_By_TUnit_Engine_Exist_With_Exact_Signatures()
{
// ItemActionAsyncProcessorBuilder<TInput, TOutput>.ProcessInParallel(int)
var builderMethod = typeof(ItemActionAsyncProcessorBuilder<,>).GetMethods()
.SingleOrDefault(m => m.Name == "ProcessInParallel"
&& m.GetParameters().Length == 1
&& m.GetParameters()[0].ParameterType == typeof(int));
await Assert.That(builderMethod).IsNotNull();
// AsyncEnumerableExtensions.ProcessInParallel<T>(IAsyncEnumerable<T>, CancellationToken)
var extensionMethod = typeof(AsyncEnumerableExtensions).GetMethods()
.SingleOrDefault(m => m.Name == "ProcessInParallel"
&& m.GetGenericArguments().Length == 1
&& m.GetParameters().Length == 2
&& m.GetParameters()[1].ParameterType == typeof(CancellationToken));
await Assert.That(extensionMethod).IsNotNull();
// TUnit.Engine also binds EnumerableExtensions.SelectAsync / SelectManyAsync and
// IAsyncProcessor<T>.GetAwaiter; these exact-signature method groups stop compiling if they drift.
Func<IEnumerable<int>, Func<int, Task<int>>, CancellationToken, ItemActionAsyncProcessorBuilder<int, int>> selectAsync =
EnumerableExtensions.SelectAsync;
Func<IEnumerable<int>, Func<int, IAsyncEnumerable<int>>, CancellationToken, IAsyncEnumerable<int>> selectManyAsync =
EnumerableExtensions.SelectManyAsync;
await Assert.That(selectAsync).IsNotNull();
await Assert.That(selectManyAsync).IsNotNull();
}
}