-
Notifications
You must be signed in to change notification settings - Fork 292
Expand file tree
/
Copy pathProxyOutputDevice.cs
More file actions
94 lines (78 loc) · 3.41 KB
/
ProxyOutputDevice.cs
File metadata and controls
94 lines (78 loc) · 3.41 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using Microsoft.Testing.Platform.Extensions.OutputDevice;
using Microsoft.Testing.Platform.Hosts;
using Microsoft.Testing.Platform.ServerMode;
namespace Microsoft.Testing.Platform.OutputDevice;
internal sealed class ProxyOutputDevice : IOutputDevice
{
private readonly ServerModePerCallOutputDevice? _serverModeOutputDevice;
public ProxyOutputDevice(IPlatformOutputDevice? originalOutputDevice, ServerModePerCallOutputDevice? serverModeOutputDevice)
{
OriginalOutputDevice = originalOutputDevice;
_serverModeOutputDevice = serverModeOutputDevice;
}
internal IPlatformOutputDevice? OriginalOutputDevice { get; }
public async Task DisplayAsync(IOutputDeviceDataProducer producer, IOutputDeviceData data, CancellationToken cancellationToken)
{
if (OriginalOutputDevice is not null)
{
await OriginalOutputDevice.DisplayAsync(producer, data, cancellationToken).ConfigureAwait(false);
}
if (_serverModeOutputDevice is not null)
{
await _serverModeOutputDevice.DisplayAsync(producer, data, cancellationToken).ConfigureAwait(false);
}
}
internal async Task DisplayBannerAsync(string? bannerMessage, CancellationToken cancellationToken)
{
if (OriginalOutputDevice is not null)
{
await OriginalOutputDevice.DisplayBannerAsync(bannerMessage, cancellationToken).ConfigureAwait(false);
}
if (_serverModeOutputDevice is not null)
{
await _serverModeOutputDevice.DisplayBannerAsync(bannerMessage, cancellationToken).ConfigureAwait(false);
}
}
internal async Task DisplayBeforeSessionStartAsync(CancellationToken cancellationToken)
{
if (OriginalOutputDevice is not null)
{
await OriginalOutputDevice.DisplayBeforeSessionStartAsync(cancellationToken).ConfigureAwait(false);
}
if (_serverModeOutputDevice is not null)
{
await _serverModeOutputDevice.DisplayBeforeSessionStartAsync(cancellationToken).ConfigureAwait(false);
}
}
internal async Task DisplayAfterSessionEndRunAsync(CancellationToken cancellationToken)
{
if (OriginalOutputDevice is not null)
{
await OriginalOutputDevice.DisplayAfterSessionEndRunAsync(cancellationToken).ConfigureAwait(false);
}
if (_serverModeOutputDevice is not null)
{
await _serverModeOutputDevice.DisplayAfterSessionEndRunAsync(cancellationToken).ConfigureAwait(false);
}
}
internal async Task InitializeAsync(ServerTestHost serverTestHost)
{
if (_serverModeOutputDevice is not null)
{
await _serverModeOutputDevice.InitializeAsync(serverTestHost).ConfigureAwait(false);
}
}
internal async Task HandleProcessRoleAsync(TestProcessRole processRole, CancellationToken cancellationToken)
{
if (OriginalOutputDevice is not null)
{
await OriginalOutputDevice.HandleProcessRoleAsync(processRole, cancellationToken).ConfigureAwait(false);
}
if (_serverModeOutputDevice is not null)
{
await _serverModeOutputDevice.HandleProcessRoleAsync(processRole, cancellationToken).ConfigureAwait(false);
}
}
}