-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated subject in fallback handler (#358)
* Updated subject in fallback handler * Added testing util to replace Task.Delay() * fix progress tests * Updated dynamic registration tests
- Loading branch information
1 parent
b0ae859
commit 4b06168
Showing
14 changed files
with
142 additions
and
67 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace TestingUtils | ||
{ | ||
public class FactWithSkipOnAttribute : FactAttribute | ||
{ | ||
private readonly SkipOnPlatform[] _platformsToSkip; | ||
private string _skip; | ||
|
||
public FactWithSkipOnAttribute(params SkipOnPlatform[] platformsToSkip) | ||
{ | ||
_platformsToSkip = platformsToSkip; | ||
} | ||
|
||
public override string Skip | ||
{ | ||
get => !UnitTestDetector.IsCI() && _platformsToSkip.Any(UnitTestDetector.PlatformToSkipPredicate) | ||
? "Skipped on platform" + ( string.IsNullOrWhiteSpace(_skip) ? "" : " because " + _skip ) | ||
: null; | ||
set => _skip = value; | ||
} | ||
} | ||
|
||
public static class TestHelper | ||
{ | ||
public static async Task DelayUntil<T>(Func<T> valueFunc, Func<T, bool> func, CancellationToken cancellationToken, TimeSpan? delay = null) | ||
{ | ||
while (true) | ||
{ | ||
if (func(valueFunc())) return; | ||
await Task.Delay(delay ?? TimeSpan.FromMilliseconds(100), cancellationToken); | ||
} | ||
} | ||
|
||
public static async Task DelayUntil(Func<bool> func, CancellationToken cancellationToken, TimeSpan? delay = null) | ||
{ | ||
while (true) | ||
{ | ||
if (func()) return; | ||
await Task.Delay(delay ?? TimeSpan.FromMilliseconds(100), cancellationToken); | ||
} | ||
} | ||
|
||
public static Task DelayUntil<T>(this T value, Func<T, bool> func, CancellationToken cancellationToken, TimeSpan? delay = null) | ||
{ | ||
return DelayUntil(() => value, func, cancellationToken, delay); | ||
} | ||
|
||
public static Task DelayUntilCount<T>(this T value, int count, CancellationToken cancellationToken, TimeSpan? delay = null) where T : IEnumerable | ||
{ | ||
return DelayUntil(() => value.OfType<object>().Count() >= count, cancellationToken, delay); | ||
} | ||
} | ||
} |
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,9 @@ | ||
namespace TestingUtils | ||
{ | ||
public enum SkipOnPlatform | ||
{ | ||
Linux, | ||
Mac, | ||
Windows, | ||
} | ||
} |
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,24 @@ | ||
using System.Linq; | ||
using Xunit; | ||
|
||
namespace TestingUtils | ||
{ | ||
public class TheoryWithSkipOnAttribute : TheoryAttribute | ||
{ | ||
private readonly SkipOnPlatform[] _platformsToSkip; | ||
private string _skip; | ||
|
||
public TheoryWithSkipOnAttribute(params SkipOnPlatform[] platformsToSkip) | ||
{ | ||
_platformsToSkip = platformsToSkip; | ||
} | ||
|
||
public override string Skip | ||
{ | ||
get => !UnitTestDetector.IsCI() && _platformsToSkip.Any(UnitTestDetector.PlatformToSkipPredicate) | ||
? "Skipped on platform" + ( string.IsNullOrWhiteSpace(_skip) ? "" : " because " + _skip ) | ||
: null; | ||
set => _skip = value; | ||
} | ||
} | ||
} |
Oops, something went wrong.