aboutsummaryrefslogtreecommitdiffstats
path: root/tests/slskd.Tests.Unit/Common/ComputeTests.cs
blob: 021d4faa8fcfdbbe494559df013ada2a1cf79864 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
namespace slskd.Tests.Unit.Common
{
    using Xunit;

    public class ComputeTests
    {
        [Theory]
        [InlineData(1, 300000, 0)]
        [InlineData(2, 300000, 1000)]
        [InlineData(3, 300000, 3000)]
        [InlineData(4, 300000, 7000)]
        [InlineData(5, 300000, 15000)]
        [InlineData(6, 300000, 31000)]
        [InlineData(999999, 300000, 300000)]
        public void ExponentialBackoffDelay(int iteration, int maxDelayInMs, int expectedDelay)
        {
            var (computedDelay, _) = Compute.ExponentialBackoffDelay(iteration, maxDelayInMs);
            Assert.Equal(expectedDelay, computedDelay);
        }
    }
}