Exemple #1
0
 public void DelayShouldCancelWithToken()
 {
     // ARRANGE
     using var tokenSource = new CancellationTokenSource(50);
     // ACT & ASSERT
     Assert.Throws <OperationCanceledException>(() => DefaultDaemonRxApp.Delay(TimeSpan.FromMilliseconds(300), tokenSource.Token));
 }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }