public async Task Test_that_stopping_token_is_cancelled_on_StopAsync_call() { var probe = new BackgroundServiceProbe(); probe.Start(); var stopTask = probe.StopAsync(); probe.CompleteExecution(); await stopTask; Assert.IsTrue(probe.StoppingToken.IsCancellationRequested); }
public async Task Test_that_StopAsync_call_waits_for_underlying_ExecutingAsync_completion() { var probe = new BackgroundServiceProbe(); probe.Start(); var stopTask = probe.StopAsync(); await Task.Delay(100); Assert.IsFalse(probe.ExecutionCompleted); probe.CompleteExecution(); await stopTask; Assert.IsTrue(probe.ExecutionCompleted); }