Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#nullable enable
Microsoft.Testing.Platform.Extensions.TestFramework.ExecuteRequestContext.ExecuteRequestContext(Microsoft.Testing.Platform.Requests.IRequest! request, Microsoft.Testing.Platform.Messages.IMessageBus! messageBus, Microsoft.Testing.Platform.Requests.IRequestCompleteNotifier! requestCompleteNotifier, System.Threading.CancellationToken cancellationToken) -> void
Microsoft.Testing.Platform.OutputDevice.FormattedTextOutputDeviceData.Padding.get -> int?
Microsoft.Testing.Platform.OutputDevice.FormattedTextOutputDeviceData.Padding.init -> void
Microsoft.Testing.Platform.Requests.IRequestCompleteNotifier
Microsoft.Testing.Platform.Requests.IRequestCompleteNotifier.Complete() -> void
[TPEXP]Microsoft.Testing.Platform.Capabilities.TestFramework.TestFrameworkCapabilitiesExtensions
[TPEXP]Microsoft.Testing.Platform.Services.IClientInfo
[TPEXP]Microsoft.Testing.Platform.Services.IClientInfo.Id.get -> string!
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace Microsoft.Testing.Platform.Requests;

public interface IRequestCompleteNotifier
Comment thread
Evangelink marked this conversation as resolved.
Resolved
{
void Complete();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace Microsoft.Testing.Platform.Requests;

internal class SemaphoreSlimRequestCompleteNotifier : IRequestCompleteNotifier
Comment thread
MarcoRossignoli marked this conversation as resolved.
Resolved
{
private readonly SemaphoreSlim _semaphore;

public SemaphoreSlimRequestCompleteNotifier(SemaphoreSlim semaphore)
{
_semaphore = semaphore;
}

public void Complete()
=> _semaphore.Release();
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public async Task ExecuteAsync(ITestFramework testFramework, ClientInfo client,
public virtual async Task ExecuteRequestAsync(ITestFramework testFramework, TestExecutionRequest request, IMessageBus messageBus, CancellationToken cancellationToken)
{
using SemaphoreSlim requestSemaphore = new(0, 1);
await testFramework.ExecuteRequestAsync(new(request, messageBus, requestSemaphore, cancellationToken));
await testFramework.ExecuteRequestAsync(new(request, messageBus, new SemaphoreSlimRequestCompleteNotifier(requestSemaphore), cancellationToken));
await requestSemaphore.WaitAsync(cancellationToken);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ namespace Microsoft.Testing.Platform.Extensions.TestFramework;
/// </remarks>
public sealed class ExecuteRequestContext
{
private readonly SemaphoreSlim _semaphore;
private readonly IRequestCompleteNotifier _requestCompleteNotifier;

internal ExecuteRequestContext(IRequest request, IMessageBus messageBus, SemaphoreSlim semaphore,
public ExecuteRequestContext(IRequest request, IMessageBus messageBus, IRequestCompleteNotifier requestCompleteNotifier,
CancellationToken cancellationToken)
{
Request = request;
MessageBus = messageBus;
_semaphore = semaphore;
_requestCompleteNotifier = requestCompleteNotifier;
CancellationToken = cancellationToken;
}

Expand All @@ -44,5 +44,5 @@ internal ExecuteRequestContext(IRequest request, IMessageBus messageBus, Semapho
/// Completes the execution request.
/// </summary>
public void Complete()
=> _semaphore.Release();
=> _requestCompleteNotifier.Complete();
}