Skip to content

Commit 4ad8479

Browse files
authored
Merge pull request #42 from wintoncode/update-test-dependencies
Update test dependencies
2 parents 9cce364 + 1783dfa commit 4ad8479

File tree

6 files changed

+108
-112
lines changed

6 files changed

+108
-112
lines changed

Winton.Extensions.Threading.Actor.Tests.Unit/ActorTests.cs

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -303,29 +303,29 @@ public async Task ShouldScheduleTaskAsLongRunningIfRequested(ActorEnqueueOptions
303303

304304
await actor.Start();
305305

306-
actor.Awaiting(x => x.Enqueue(() => ValidateActorThread(enqueueOptions), enqueueOptions)).Should().NotThrow();
307-
actor.Awaiting(
306+
await actor.Awaiting(x => x.Enqueue(() => ValidateActorThread(enqueueOptions), enqueueOptions)).Should().NotThrowAsync();
307+
await actor.Awaiting(
308308
x => x.Enqueue(
309309
() =>
310310
{
311311
ValidateActorThread(enqueueOptions);
312312
return 676;
313-
}, enqueueOptions)).Should().NotThrow();
314-
actor.Awaiting(
313+
}, enqueueOptions)).Should().NotThrowAsync();
314+
await actor.Awaiting(
315315
x => x.Enqueue(
316316
async () =>
317317
{
318318
await Task.Yield();
319319
ValidateActorThread(enqueueOptions);
320-
}, enqueueOptions)).Should().NotThrow();
321-
actor.Awaiting(
320+
}, enqueueOptions)).Should().NotThrowAsync();
321+
await actor.Awaiting(
322322
x => x.Enqueue(
323323
async () =>
324324
{
325325
await Task.Yield();
326326
ValidateActorThread(enqueueOptions);
327327
return "moose";
328-
}, enqueueOptions)).Should().NotThrow();
328+
}, enqueueOptions)).Should().NotThrowAsync();
329329

330330
}
331331

@@ -349,7 +349,7 @@ public void ShouldBeAbleToSpecifyWorkToRunAtStartUpWhichIsGuaranteedToBeTheFirst
349349
}
350350

351351
[Fact]
352-
public void ShouldNotEnqueueAnyMoreWorkAfterAskedToStop()
352+
public async Task ShouldNotEnqueueAnyMoreWorkAfterAskedToStop()
353353
{
354354
var stageOrder = new List<string>();
355355
var expectedStageOrder =
@@ -377,7 +377,7 @@ public void ShouldNotEnqueueAnyMoreWorkAfterAskedToStop()
377377

378378
MarkAlreadyStopped();
379379

380-
ShouldBeCancelled(lateWork);
380+
await ShouldBeCancelled(lateWork);
381381
stopTask.AwaitingShouldCompleteIn(_waitTimeout);
382382

383383
stageOrder.Should().Equal(expectedStageOrder);
@@ -441,7 +441,7 @@ public async Task ShouldCancelStoppedTokenWhenStopCompleted()
441441
[InlineData(ResumeTestCase.AwaitOnTaskFactoryScheduledTask, StopWorkOutcome.Faults)]
442442
[InlineData(ResumeTestCase.AwaitOnSecondActor, StopWorkOutcome.Completes)]
443443
[InlineData(ResumeTestCase.AwaitOnSecondActor, StopWorkOutcome.Faults)]
444-
public void ShouldNotBeAbleToResumeWorkAfterStop(ResumeTestCase resumeTestCase, StopWorkOutcome stopWorkOutcome)
444+
public async Task ShouldNotBeAbleToResumeWorkAfterStop(ResumeTestCase resumeTestCase, StopWorkOutcome stopWorkOutcome)
445445
{
446446
var actor1 = CreateActor(
447447
x => x.StopWork = new ActorStopWork(
@@ -508,7 +508,7 @@ int OffActorWork()
508508
stopTask.AwaitingShouldCompleteIn(_waitTimeout);
509509
break;
510510
case StopWorkOutcome.Faults:
511-
((Func<Task>)(async () => await stopTask)).Should().Throw<InvalidOperationException>().WithMessage("Never meant to be");
511+
await ((Func<Task>)(async () => await stopTask)).Should().ThrowAsync<InvalidOperationException>().WithMessage("Never meant to be");
512512
break;
513513
default:
514514
throw new Exception($"Unhandled test case {stopWorkOutcome}.");
@@ -555,7 +555,7 @@ public void ShouldNotProcessAnyWorkUntilAsyncStartUpWorkIsComplete()
555555
}
556556

557557
[Fact]
558-
public void ShouldNotStartProcessingIfStopAlreadyCalled()
558+
public async Task ShouldNotStartProcessingIfStopAlreadyCalled()
559559
{
560560
var stageOrder = new List<string>();
561561
var actor = CreateActor(x =>
@@ -582,8 +582,8 @@ public void ShouldNotStartProcessingIfStopAlreadyCalled()
582582

583583
stageOrder.Should().BeEmpty();
584584

585-
ShouldBeCancelled(shouldBeCancelled[0]);
586-
ShouldBeCancelled(shouldBeCancelled[1]);
585+
await ShouldBeCancelled(shouldBeCancelled[0]);
586+
await ShouldBeCancelled(shouldBeCancelled[1]);
587587
}
588588

589589
[Fact]
@@ -648,7 +648,7 @@ public void ShouldProcessAlreadyQueuedWorkBeforeSignallingStoppedWhenAskedToStop
648648
[Theory]
649649
[InlineData(ActorEnqueueOptions.WorkIsLongRunning)]
650650
[InlineData(ActorEnqueueOptions.Default)]
651-
public void ShouldScheduleStartTaskAsLongRunningIfRequested(ActorEnqueueOptions startOptions)
651+
public async Task ShouldScheduleStartTaskAsLongRunningIfRequested(ActorEnqueueOptions startOptions)
652652
{
653653
var actor = new Actor
654654
{
@@ -658,7 +658,7 @@ public void ShouldScheduleStartTaskAsLongRunningIfRequested(ActorEnqueueOptions
658658
}
659659
};
660660

661-
actor.Awaiting(x => x.Start()).Should().NotThrow();
661+
await actor.Awaiting(x => x.Start()).Should().NotThrowAsync();
662662
}
663663

664664
[Theory]
@@ -676,7 +676,7 @@ public async Task ShouldScheduleStopTaskAsLongRunningIfRequested(ActorEnqueueOpt
676676

677677
await actor.Start();
678678

679-
actor.Awaiting(x => x.Stop()).Should().NotThrow();
679+
await actor.Awaiting(x => x.Stop()).Should().NotThrowAsync();
680680
}
681681

682682
[Fact]
@@ -919,16 +919,16 @@ public async Task ShouldBeAbleToCancelAnyEnqueuedWork(bool delayStart)
919919
await task4;
920920
await task6;
921921
await task8;
922-
ShouldBeCancelled(task2);
923-
ShouldBeCancelled(task3);
924-
ShouldBeCancelled(task5);
925-
ShouldBeCancelled(task7);
922+
await ShouldBeCancelled(task2);
923+
await ShouldBeCancelled(task3);
924+
await ShouldBeCancelled(task5);
925+
await ShouldBeCancelled(task7);
926926
}
927927

928928
[Theory]
929929
[InlineData(StopTaskCancellationTestCase.CancelDuringWork)]
930930
[InlineData(StopTaskCancellationTestCase.CancelPriorToInvoke)]
931-
public void ShouldBeAbleToCancelStopWorkButNotTermination(StopTaskCancellationTestCase testCase)
931+
public async Task ShouldBeAbleToCancelStopWorkButNotTermination(StopTaskCancellationTestCase testCase)
932932
{
933933
var cancellationTokenSource = new CancellationTokenSource();
934934
var startedStopWorkFlag = new TaskCompletionSource<bool>();
@@ -959,18 +959,18 @@ public void ShouldBeAbleToCancelStopWorkButNotTermination(StopTaskCancellationTe
959959
throw new Exception($"Unhandled test case {testCase}.");
960960
}
961961

962-
ShouldBeCancelled(stopTask);
962+
await ShouldBeCancelled(stopTask);
963963

964964
if (testCase == StopTaskCancellationTestCase.CancelPriorToInvoke)
965965
{
966966
startedStopWorkFlag.Task.Wait(TimeSpan.FromSeconds(1)).Should().BeFalse();
967967
}
968968

969-
ShouldBeCancelled(actor.Enqueue(() => { }));
969+
await ShouldBeCancelled(actor.Enqueue(() => { }));
970970
}
971971

972972
[Fact]
973-
public void ShouldNotFailEnqueuingWorkAlreadyCancelled()
973+
public async Task ShouldNotFailEnqueuingWorkAlreadyCancelled()
974974
{
975975
var actor = CreateActor();
976976

@@ -993,14 +993,14 @@ public void ShouldNotFailEnqueuingWorkAlreadyCancelled()
993993
return "moose";
994994
}, cancellationTokenSource4.Token);
995995

996-
ShouldBeCancelled(task1);
997-
ShouldBeCancelled(task2);
998-
ShouldBeCancelled(task3);
999-
ShouldBeCancelled(task4);
996+
await ShouldBeCancelled(task1);
997+
await ShouldBeCancelled(task2);
998+
await ShouldBeCancelled(task3);
999+
await ShouldBeCancelled(task4);
10001000
}
10011001

10021002
[Fact]
1003-
public void ShouldStopActorAndNotProcessAnyAlreadyEnqueuedWorkIfStartWorkCancelled()
1003+
public async Task ShouldStopActorAndNotProcessAnyAlreadyEnqueuedWorkIfStartWorkCancelled()
10041004
{
10051005
var cancellationTokenSource = new CancellationTokenSource();
10061006
var actor = CreateActor(x => x.StartWork = new ActorStartWork(() => { Task.Delay(TimeSpan.FromMinutes(1)).Wait(cancellationTokenSource.Token); }, cancellationTokenSource.Token),
@@ -1014,9 +1014,9 @@ public void ShouldStopActorAndNotProcessAnyAlreadyEnqueuedWorkIfStartWorkCancell
10141014
MarkAlreadyStopped();
10151015
cancellationTokenSource.Cancel();
10161016

1017-
ShouldBeCancelled(startTask);
1018-
ShouldBeCancelled(task);
1019-
ShouldBeCancelled(actor.Enqueue(() => { }));
1017+
await ShouldBeCancelled(startTask);
1018+
await ShouldBeCancelled(task);
1019+
await ShouldBeCancelled(actor.Enqueue(() => { }));
10201020
attempts.Should().Be(0);
10211021
}
10221022

@@ -1110,7 +1110,7 @@ public async Task StopShouldNotRunStopWorkIfStartWorkFails()
11101110
StopWork = new ActorStopWork(() => stopWorkCalled = true)
11111111
};
11121112

1113-
actor.Awaiting(x => x.Start()).Should().Throw<Exception>().WithMessage("Error.");
1113+
await actor.Awaiting(x => x.Start()).Should().ThrowAsync<Exception>().WithMessage("Error.");
11141114

11151115
await actor.Stop();
11161116

@@ -1146,9 +1146,9 @@ private IActor CreateActor(Action<IActor> setup, ActorCreateOptions options = Ac
11461146
return actor;
11471147
}
11481148

1149-
private static void ShouldBeCancelled(Task task)
1149+
private static async Task ShouldBeCancelled(Task task)
11501150
{
1151-
Expect.That(async () => await task).Should().Throw<OperationCanceledException>();
1151+
await Expect.That(async () => await task).Should().ThrowAsync<OperationCanceledException>();
11521152
}
11531153

11541154
private void MarkAlreadyStopped()

0 commit comments

Comments
 (0)