public void Delay_WhenCalledWithATimeSpanGreaterThanIntMaxValue_AndACancellationToken_ShouldRaiseAnException() { var delay = TimeSpan.FromMilliseconds(1 + (long)int.MaxValue); var token = new CancellationToken(); Assert.Throws <ArgumentOutOfRangeException>(() => TimeService.Delay(delay, token)); }
public void Delay_FromMillisecondsDelayAndCancellationToken_ShouldRaiseAnError() { var delay = 1000; var cancellationToken = new CancellationTokenSource().Token; Assert.Throws <ObjectDisposedException>(() => TimeService.Delay(delay, cancellationToken)); }
public void Delay_FromTimeStampAndCancellationToken_ShouldRaiseAnError() { var delay = TimeSpan.FromSeconds(1); var cancellationToken = new CancellationTokenSource().Token; Assert.Throws <ObjectDisposedException>(() => TimeService.Delay(delay, cancellationToken)); }
public void Delay_WhenCalledWithANegativeTimeSpanInMilliseconds_AndACancellationToken_ShouldRaiseAnException() { var delay = -2; var token = new CancellationToken(); Assert.Throws <ArgumentOutOfRangeException>(() => TimeService.Delay(delay, token)); }
public override void SetUp() { base.SetUp(); TimeService.MoveForwardBy(TimeSpan.FromSeconds(0.5)); TimeService.Delay(TimeSpan.FromSeconds(2)); TimeService.MoveForwardBy(TimeSpan.FromSeconds(0.5)); TestStartTime += TimeSpan.FromSeconds(1); }
public void WhenDelayIsCalledWithACancelledCancellationToken_ItShouldReturnAnImmediatelyCancelledTask() { var token = new CancellationToken(true); var task = TimeService.Delay(1000, token); var aggregateException = Assert.Throws <AggregateException>(task.Wait); Assert.That(aggregateException.InnerExceptions.First(), Is.InstanceOf <TaskCanceledException>()); }
public void WhenDelayIsCalledWithACancellationToken_ThatIsSubsequentlyCancelled_TheTaskShouldRaiseAnException() { var source = new CancellationTokenSource(); var delayTask = TimeService.Delay(1000, source.Token); TimeService.MoveForwardBy(500); source.Cancel(); var aggregateException = Assert.Throws <AggregateException>(() => delayTask.Wait(10)); Assert.That(aggregateException.InnerExceptions.First(), Is.InstanceOf <TaskCanceledException>()); }
public void Delay_FromMillisecondsDelay_ShouldRaiseAnError() { var delay = 1000; Assert.Throws <ObjectDisposedException>(() => TimeService.Delay(delay)); }
public void Delay_FromTimeStamp_ShouldRaiseAnError() { var delay = TimeSpan.FromSeconds(1); Assert.Throws <ObjectDisposedException>(() => TimeService.Delay(delay)); }
public override void SetUp() { base.SetUp(); _delayTask = TimeService.Delay(0); }
public void Delay_WhenCalledWithANegativeTimeSpanInMilliseconds_ShouldRaiseAnException() { var delay = -2; Assert.Throws <ArgumentOutOfRangeException>(() => TimeService.Delay(delay)); }