public void GetNoWork()
        {
            var random = new Random();
            var expected = random.NextDouble();
            var timing = Substitute.For<ICalculateTiming>();
            timing.Get(0).Returns(expected);

            var t = new AdaptiveTiming(timing);
            var value = t.Get(false);

            Assert.AreEqual(expected, value);

            timing.Received().Get(0);
        }
        public void GetNoWorkMultiple()
        {
            var random = new Random();
            var expected = random.NextDouble();
            var timing = Substitute.For<ICalculateTiming>();
            timing.FrequencyInSeconds.Returns(new Range<int>(1, 100000));
            timing.Get(6).Returns(expected);

            var t = new AdaptiveTiming(timing);
            t.Get(false);
            t.Get(false);
            t.Get(false);
            t.Get(false);
            t.Get(false);
            var value = t.Get(false);

            Assert.AreEqual(expected, value);

            timing.Received().Get(1);
            timing.Received().Get(2);
            timing.Received().Get(3);
            timing.Received().Get(4);
            timing.Received().Get(5);
            timing.Received().Get(6);
            var r = timing.Received().FrequencyInSeconds;
        }
        public void GetMaxThenMin()
        {
            var min = 1;
            var max = 10;
            var t = new AdaptiveTiming(min, max);
            while (max > t.Get(false))
            { }

            Assert.AreEqual(max, t.Get(false));
            Assert.AreEqual(max, t.Get(false));
            
            var result = t.Get(true);
            Assert.IsTrue(result < max);
        }