public void ThrowsAnExceptionWhenStopAfterDispose() { var api = new Mock <IRasConnectionNotification>(); var target = new RasConnectionWatcher(api.Object); target.Dispose(); Assert.Throws <ObjectDisposedException>(() => target.Stop()); }
private void Run() { // Start watching for connection changes. watcher.Start(); Console.WriteLine("Press any key to stop watching for connection changes..."); Console.ReadKey(true); // Stop watching for connection changes. watcher.Stop(); }
public void StopWillResetTheApi() { var api = new Mock <IRasConnectionNotification>(); api.Setup(o => o.IsActive).Returns(true); var target = new RasConnectionWatcher(api.Object); target.Stop(); api.Verify(o => o.Reset(), Times.Once); }
private async Task RunCoreAsync() { watcher.Start(); while (ShouldContinueExecution()) { using var tcs = CancellationTokenSource.CreateLinkedTokenSource(CancellationSource.Token); try { await RunOnceAsync(tcs.Token); } finally { await WaitForALittleWhileAsync(tcs.Token, false); } } watcher.Stop(); }