forked from ddrilling/AsbCloudServer
fix PeriodicBackgroundWorkerTest.Enqueue_Continues_AfterExceptions
This commit is contained in:
parent
0b629afcf0
commit
beb0d08ff5
@ -67,10 +67,12 @@ public class PeriodicBackgroundWorkerTest
|
||||
{
|
||||
var expectadResult = 42;
|
||||
var result = 0;
|
||||
using var semaphore = new SemaphoreSlim(0, 1);
|
||||
|
||||
Task workAction(string id, IServiceProvider services, Action<string, double?> callback, CancellationToken token)
|
||||
{
|
||||
result = expectadResult;
|
||||
semaphore.Release();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
var goodWork = Work.CreateByDelegate("", workAction);
|
||||
@ -85,12 +87,12 @@ public class PeriodicBackgroundWorkerTest
|
||||
service.Add(badWork, TimeSpan.FromSeconds(2));
|
||||
service.Add(goodWork, TimeSpan.FromSeconds(2));
|
||||
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(256));
|
||||
await semaphore.WaitAsync(4_100);
|
||||
|
||||
//assert
|
||||
Assert.Equal(expectadResult, result);
|
||||
Assert.Equal(1, badWork.CountErrors);
|
||||
Assert.Equal(1, goodWork.CountComplete);
|
||||
Assert.Equal(1, goodWork.CountStart);
|
||||
Assert.Equal(expectadResult, result);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user