public void Should_call_method_at_least_once() { // Arrange var mockThreadJob = new Mock <ITestThreadJob>(); var stopableThread = new StopableThread(new TimeSpan(), mockThreadJob.Object.Do); // Act stopableThread.Start(); // Assert mockThreadJob.Verify(job => job.Do(), Times.AtLeastOnce); }
public void Thread_should_stop() { // Arrange var stopableThread = new StopableThread(new TimeSpan(0, 0, 1), () => { }); // Act stopableThread.Start(); stopableThread.Stop(); // Assert Assert.IsFalse(stopableThread.IsRunning); }
public void Thread_should_start() { // Arrange var stopableThread = new StopableThread(new TimeSpan(0, 0, 0, 1), () => { }); // Act stopableThread.Start(); // Give time for starting Thread.Sleep(5); // Assert Assert.IsTrue(stopableThread.IsRunning); }
private static void SetLoggingThread() { if (autoProcess) { if (logThread == null) { logThread = StopableThread.StartNew(null, null, PipeTick, "DeJong Logging"); } else if (!logThread.Running) { logThread.Start(); } } else if (logThread != null && logThread.Running) { logThread.Stop(); } }