Skip to content

Commit

Permalink
increased timeout + cleanup (#7175)
Browse files Browse the repository at this point in the history
  • Loading branch information
majastrz authored Jun 10, 2022
1 parent 1c89da4 commit 5afc312
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@
// Licensed under the MIT License.

using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;

namespace Bicep.LangServer.IntegrationTests
{
// helper class to read messages in order and assert things about them
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "Test code does not need to follow this convention.")]
/// <summary>
/// Helper class to read messages in order and assert things about them.
/// </summary>
public class MultipleMessageListener<T>
{
private object lockObj = new object();
private const int DefaultTimeout = 30000;

private readonly object lockObj = new();
private readonly List<TaskCompletionSource<T>> completionSources = new();

private int listenPosition = 0;
private int writePosition = 0;
private List<TaskCompletionSource<T>> completionSources = new List<TaskCompletionSource<T>>();
private int writePosition = 0;

public async Task<T> WaitNext(int timeout = 10000)
public async Task<T> WaitNext(int timeout = DefaultTimeout)
{
Task<T> onMessageTask;
lock (lockObj)
Expand All @@ -33,7 +36,7 @@ public async Task<T> WaitNext(int timeout = 10000)
return await IntegrationTestHelper.WithTimeoutAsync(onMessageTask, timeout);
}

public async Task EnsureNoMessageSent(int timeout = 10000)
public async Task EnsureNoMessageSent(int timeout = DefaultTimeout)
{
Task<T> onMessageTask;
lock (lockObj)
Expand Down

0 comments on commit 5afc312

Please sign in to comment.