aboutsummaryrefslogtreecommitdiffstats
path: root/tests/slskd.Tests.Unit/Common/ComputeTests.cs
blob: 5a7922f68fcc4f1f68ae1344d8f454ec2e1e46ce (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
{
    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);
        }
    }
}