public async Task Start_NotStop_Should_Running() { using (var simpleDaemon = new SimpleDaemon()) { var config = TimeSpan.FromMilliseconds(10); var mockTask = MockTask.Create(); var startResult = await simpleDaemon.Start(config, mockTask.MockAction, false).ConfigureAwait(false); startResult.Success.ShouldTrue(); startResult.Message.Log(); var lastInvokeCount = 0; for (int i = 0; i < 5; i++) { await Task.Delay(20).ConfigureAwait(false); var isRunning = mockTask.InvokeCount >= lastInvokeCount; string.Format("Running Invoked: {0}", mockTask.InvokeCount).Log(); isRunning.ShouldTrue(); lastInvokeCount = mockTask.InvokeCount; } var stopResult = await simpleDaemon.Stop(); stopResult.Success.ShouldTrue(); stopResult.Message.Log(); } }
public async Task Stop_NotRunning_Should_Ignore() { using (var simpleDaemon = new SimpleDaemon()) { var startResult = await simpleDaemon.Stop().ConfigureAwait(false); startResult.Success.ShouldTrue(); startResult.Message.Log(); } }
public async Task Stop_SecondTime_Should_Ignore() { using (var simpleDaemon = new SimpleDaemon()) { var config = TimeSpan.FromMilliseconds(50); var mockTask = MockTask.Create(); var startResult = await simpleDaemon.Start(config, mockTask.MockAction, false).ConfigureAwait(false); startResult.Success.ShouldTrue(); startResult.Message.Log(); var stopResult = await simpleDaemon.Stop().ConfigureAwait(false); stopResult.Success.ShouldTrue(); stopResult.Message.Log(); var stopResult2 = await simpleDaemon.Stop().ConfigureAwait(false); stopResult2.Success.ShouldTrue(); stopResult2.Message.Log(); } }