public async Task Run_LoopsUntilShutdownSignal() { shutdown.SetupGet(s => s.ShouldShutdown).Returns(false); var t = Task.Run(() => testThread.Run()); await Task.Delay(10); Assert.IsFalse(t.IsCompleted); await Task.Delay(10); Assert.IsFalse(t.IsCompleted); shutdown.SetupGet(s => s.ShouldShutdown).Returns(true); await Task.Delay(10); Assert.IsTrue(t.IsCompleted); await t; }