-
Notifications
You must be signed in to change notification settings - Fork 748
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade xunit to 2.8.0 and fix compiler warnings
- Loading branch information
Showing
13 changed files
with
104 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace NetMQ.Tests | ||
{ | ||
internal class TaskUtils | ||
{ | ||
internal static async Task PollUntil(Func<bool> condition, TimeSpan timeout) | ||
{ | ||
var cts = new CancellationTokenSource(); | ||
cts.CancelAfter(timeout); | ||
|
||
await PollUntil(condition, cts.Token); | ||
} | ||
|
||
internal static async Task PollUntil(Func<bool> condition, CancellationToken ct = default) | ||
{ | ||
try | ||
{ | ||
while (!condition()) | ||
{ | ||
await Task.Delay(25, ct).ConfigureAwait(true); | ||
} | ||
} | ||
catch (TaskCanceledException) | ||
{ | ||
// Task was cancelled. Ignore exception and return. | ||
} | ||
} | ||
|
||
internal static bool WaitAll(IEnumerable<Task> tasks, TimeSpan timeout) | ||
{ | ||
PollUntil(() => tasks.All(t => t.IsCompleted), timeout).Wait(); | ||
return tasks.All(t => t.Status == TaskStatus.RanToCompletion); | ||
} | ||
|
||
internal static void WaitAll(IEnumerable<Task> tasks) | ||
{ | ||
PollUntil(() => tasks.All(t => t.IsCompleted), Timeout.InfiniteTimeSpan).Wait(); | ||
} | ||
|
||
internal static bool Wait(Task task, TimeSpan timeout) | ||
{ | ||
PollUntil(() => task.IsCompleted, timeout).Wait(); | ||
return task.Status == TaskStatus.RanToCompletion; | ||
} | ||
|
||
internal static void Wait(Task task) | ||
{ | ||
PollUntil(() => task.IsCompleted, Timeout.InfiniteTimeSpan).Wait(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters