Example #1
0
        public void CompositeWithAverageSelectorReturnsAverageWaitTime()
        {
            var strategy = new CompositeBackoffStrategy(_strategies, waitTimes => TimeSpan.FromMilliseconds(waitTimes.Average(time => time.TotalMilliseconds)));
            var waitTime = strategy.Next();

            Assert.Equal(TimeSpan.FromMilliseconds(_initialWaitTimes.Average(time => time.TotalMilliseconds)), waitTime);
        }
Example #2
0
        public void CompositeWithMinSelectorReturnsMinWaitTime()
        {
            var strategy = new CompositeBackoffStrategy(_strategies, waitTimes => waitTimes.Min());
            var waitTime = strategy.Next();

            Assert.Equal(_initialWaitTimes.Min(), waitTime);
        }
Example #3
0
        public void CompositeSelectorReturnsCompletelyDifferentWaitTime()
        {
            var completelyDifferentWaitTime = TimeSpan.FromSeconds(23);
            var strategy = new CompositeBackoffStrategy(_strategies, waitTimes => completelyDifferentWaitTime);
            var waitTime = strategy.Next();

            Assert.Equal(completelyDifferentWaitTime, waitTime);
        }