public void Cancel_TriggersCommandCancellationToken() { // Arrange using (EventWaitHandle executeStarted = new ManualResetEvent(initialState: false)) using (EventWaitHandle executeFinished = new ManualResetEvent(initialState: false)) { bool cancellationTokenSignalled = false; ITaskSeriesCommand command = CreateCommand((cancellationToken) => { Assert.True(executeStarted.Set()); // Guard cancellationTokenSignalled = cancellationToken.WaitHandle.WaitOne(1000); Assert.True(executeFinished.Set()); // Guard return(new TaskSeriesCommandResult(wait: Task.Delay(0))); }); using (ITaskSeriesTimer product = CreateProductUnderTest(command)) { product.Start(); Assert.True(executeStarted.WaitOne(1000)); // Guard // Act product.Cancel(); // Assert Assert.True(executeFinished.WaitOne(1000)); // Guard Assert.True(cancellationTokenSignalled); // Cleanup product.StopAsync(CancellationToken.None).GetAwaiter().GetResult(); } } }
public void Cancel_IfDisposed_Throws() { // Arrange ITaskSeriesCommand command = CreateDummyCommand(); ITaskSeriesTimer product = CreateProductUnderTest(command); product.Dispose(); // Act & Assert ExceptionAssert.ThrowsObjectDisposed(() => product.Cancel()); }
public void Cancel() { ThrowIfDisposed(); _timer.Cancel(); }
public void EnsureAllCanceled() { _strategy.Cancel(); _timer.Cancel(); }
public void Cancel() { _timer.Cancel(); _innerListener.Cancel(); }