forked from SignalR/SignalR
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating xunit version in SignalR tests
- Loading branch information
Showing
6 changed files
with
77 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" /> | ||
<package id="xunit" version="2.2.0" targetFramework="net452" /> | ||
<package id="xunit.abstractions" version="2.0.1" targetFramework="net452" /> | ||
<package id="xunit.assert" version="2.2.0" targetFramework="net452" /> | ||
<package id="xunit.core" version="2.2.0" targetFramework="net452" /> | ||
<package id="xunit.extensibility.core" version="2.2.0" targetFramework="net452" /> | ||
<package id="xunit.extensibility.execution" version="2.2.0" targetFramework="net452" /> | ||
</packages> |
45 changes: 45 additions & 0 deletions
45
tests/Microsoft.AspNet.SignalR.Tests.Common/Infrastructure/TaskExtensions.cs
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,45 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.AspNet.SignalR.Infrastructure | ||
{ | ||
public static class TaskExtensions | ||
{ | ||
private const int DefaultTimeout = 5000; | ||
|
||
public static Task OrTimeout(this Task task, int milliseconds = DefaultTimeout) | ||
{ | ||
return OrTimeout(task, new TimeSpan(0, 0, 0, 0, milliseconds)); | ||
} | ||
|
||
public static async Task OrTimeout(this Task task, TimeSpan timeout) | ||
{ | ||
var completed = await Task.WhenAny(task, Task.Delay(timeout)); | ||
if (completed != task) | ||
{ | ||
throw new TimeoutException(); | ||
} | ||
|
||
await task; | ||
} | ||
|
||
public static Task<T> OrTimeout<T>(this Task<T> task, int milliseconds = DefaultTimeout) | ||
{ | ||
return OrTimeout(task, new TimeSpan(0, 0, 0, 0, milliseconds)); | ||
} | ||
|
||
public static async Task<T> OrTimeout<T>(this Task<T> task, TimeSpan timeout) | ||
{ | ||
var completed = await Task.WhenAny(task, Task.Delay(timeout)); | ||
if (completed != task) | ||
{ | ||
throw new TimeoutException(); | ||
} | ||
|
||
return await task; | ||
} | ||
} | ||
} |
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