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