-
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.
- Loading branch information
jmd
authored and
jmd
committed
Feb 6, 2024
1 parent
f2122fb
commit ca6c92c
Showing
5 changed files
with
42 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace DotJEM.Web.Scheduler.Test; | ||
|
||
internal static class TaskExt | ||
{ | ||
public static void FireAndForget(this Task task) | ||
{ | ||
|
||
} | ||
public static Func<T, Task> ToAsync<T>(this Action<T> action) | ||
{ | ||
#pragma warning disable CS1998 | ||
return async arg => action(arg); | ||
#pragma warning restore CS1998 | ||
} | ||
} |
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,21 @@ | ||
using NUnit.Framework; | ||
|
||
namespace DotJEM.Web.Scheduler.Test; | ||
|
||
public class WebTaskSchedulerTest | ||
{ | ||
[Test] | ||
public async Task SayHello_ReturnsHello() | ||
{ | ||
WebTaskScheduler scheduler = new WebTaskScheduler(); | ||
IScheduledTask? task = null; | ||
bool called = false; | ||
task = scheduler.ScheduleTask("Foo", timedOut => { called = true; }, TimeSpan.FromMilliseconds(500)); | ||
await Task.WhenAny(task.WhenCompleted(), Task.Delay(TimeSpan.FromSeconds(1))); | ||
task.Dispose(); | ||
|
||
|
||
Assert.IsTrue(called); | ||
|
||
} | ||
} |
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