Esempio n. 1
0
        public int TimeShouldIncreaseExponentially(int calls)
        {
            //Arrange
            var backo = new Backo(jitter: 0);

            //Act
            for (var i = 0; i < calls - 1; i++)
            {
                backo.AttemptTime();
            }
            var time = backo.AttemptTime();

            //Assert
            return(time);
        }
Esempio n. 2
0
        public int TimeShouldDependOnFactor(int calls, byte factor)
        {
            //Arrange
            var backo = new Backo(jitter: 0, factor: factor);

            //Act
            for (var i = 0; i < calls - 1; i++)
            {
                backo.AttemptTime();
            }

            var time = backo.AttemptTime();

            //Assert
            return(time);
        }
Esempio n. 3
0
        public int TimeShouldDependOnMin(int calls, int min)
        {
            //Arrange
            var backo = new Backo(jitter: 0, min: min);

            //Act
            for (var i = 0; i < calls - 1; i++)
            {
                backo.AttemptTime();
            }

            var time = backo.AttemptTime();

            //Assert
            return(time);
        }
Esempio n. 4
0
        public int TimeShouldBeLessOrEqualToMax(int calls, int max)
        {
            //Arrange
            var backo = new Backo(jitter: 0, max: max);

            //Act
            for (var i = 0; i < calls - 1; i++)
            {
                backo.AttemptTime();
            }

            var time = backo.AttemptTime();

            //Assert
            return(time);
        }
Esempio n. 5
0
        public void AJitterShouldBeAdded(int calls, ushort jitter, int expectedTime)
        {
            //Arrange
            var backo = new Backo(jitter: jitter);

            //Act
            for (var i = 0; i < calls - 1; i++)
            {
                backo.AttemptTime();
            }

            var time = backo.AttemptTime();

            //Assert
            Assert.IsTrue(time >= expectedTime);
            Assert.IsTrue(time - expectedTime <= jitter);
        }