public void CreateNext_HandlesExceptionsFromPreviousTokenRegistration() { using var series = new CancellationSeries(); var token1 = series.CreateNext(); var exception = new Exception(); token1.Register(() => throw exception); var aggregateException = Assert.Throws <AggregateException>(() => series.CreateNext()); Assert.Same(exception, aggregateException.InnerExceptions.Single()); Assert.True(token1.IsCancellationRequested); }
public void CreateNext_CancelsPreviousToken() { using var series = new CancellationSeries(); var token1 = series.CreateNext(); Assert.False(token1.IsCancellationRequested); var token2 = series.CreateNext(); Assert.True(token1.IsCancellationRequested); Assert.False(token2.IsCancellationRequested); var token3 = series.CreateNext(); Assert.True(token2.IsCancellationRequested); Assert.False(token3.IsCancellationRequested); }