-
Notifications
You must be signed in to change notification settings - Fork 292
Expand file tree
/
Copy pathRetryExtensions.cs
More file actions
41 lines (34 loc) · 1.65 KB
/
RetryExtensions.cs
File metadata and controls
41 lines (34 loc) · 1.65 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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under dual-license. See LICENSE.PLATFORMTOOLS.txt file in the project root for full license information.
using Microsoft.Testing.Extensions.Policy;
using Microsoft.Testing.Extensions.Policy.Resources;
using Microsoft.Testing.Platform.Builder;
using Microsoft.Testing.Platform.Extensions;
namespace Microsoft.Testing.Extensions;
/// <summary>
/// Extension methods for adding the retry provider to the test application.
/// </summary>
public static class RetryExtensions
{
/// <summary>
/// Adds the retry provider to the test application.
/// </summary>
/// <param name="builder">The test application builder.</param>
[UnsupportedOSPlatform("browser")]
public static void AddRetryProvider(this ITestApplicationBuilder builder)
{
if (OperatingSystem.IsBrowser())
{
throw new PlatformNotSupportedException(ExtensionResources.RetryExtensionNotSupportedOnBrowserErrorMessage);
}
builder.CommandLine.AddProvider(() => new RetryCommandLineOptionsProvider());
builder.TestHost.AddTestHostApplicationLifetime(serviceProvider
=> new RetryLifecycleCallbacks(serviceProvider));
CompositeExtensionFactory<RetryDataConsumer> compositeExtensionFactory
= new(serviceProvider => new RetryDataConsumer(serviceProvider));
builder.TestHost.AddDataConsumer(compositeExtensionFactory);
builder.TestHost.AddTestSessionLifetimeHandler(compositeExtensionFactory);
builder.TestHostOrchestrator
.AddTestHostOrchestrator(serviceProvider => new RetryOrchestrator(serviceProvider));
}
}