コード例 #1
0
    public async Task WaitAsyncDoesPause()
    {
        // Arrange
        var backoffStrategy = new DefaultBackoffStrategy(new[]
        {
            TimeSpan.FromMilliseconds(500)
        }, new Options());

        // Act
        var stopwatch = Stopwatch.StartNew();
        await backoffStrategy.WaitAsync(CancellationToken.None);

        stopwatch.Stop();

        // Assert
        Assert.That(stopwatch.Elapsed, Is.GreaterThan(TimeSpan.FromMilliseconds(450)).And.LessThan(TimeSpan.FromMilliseconds(550)));
    }
コード例 #2
0
        public async Task WaitAsyncDoesPause()
        {
            // Arrange
            var backoffStrategy = new DefaultBackoffStrategy(new[]
            {
                TimeSpan.FromMilliseconds(500)
            });

            // Act
            var stopwatch = Stopwatch.StartNew();
            await backoffStrategy.WaitAsync();

            stopwatch.Stop();

            // Assert
            Assert.GreaterOrEqual(stopwatch.Elapsed, TimeSpan.FromMilliseconds(500));
        }