public void DelayShouldCancelWithToken() { // ARRANGE using var tokenSource = new CancellationTokenSource(50); // ACT & ASSERT Assert.Throws <OperationCanceledException>(() => DefaultDaemonRxApp.Delay(TimeSpan.FromMilliseconds(300), tokenSource.Token)); }
public void DelayShouldDelaySyncronysly() { // ARRANGE var startTime = DateTime.Now; // ACT DefaultDaemonRxApp.Delay(TimeSpan.FromMilliseconds(100)); // Compensate that windows resolution is 15ms for system clock bool isAfterTimeout = DateTime.Now.Subtract(startTime).TotalMilliseconds >= 84; // ASSERT Assert.True(isAfterTimeout); }
public void DelayShouldDelaySyncronyslyWithToken() { // ARRANGE var startTime = DateTime.Now; using var tokenSource = new CancellationTokenSource(); // ACT DefaultDaemonRxApp.Delay(TimeSpan.FromMilliseconds(100), tokenSource.Token); // ASSERT // Compensate that windows resolution is 15ms for system clock bool isAfterTimeout = DateTime.Now.Subtract(startTime).TotalMilliseconds >= 84; Assert.True(isAfterTimeout); }