示例#1
0
        public void IntervalUpdatedAfterStartShouldNotChangeTheIntervalUntilStartHasBeenCalled()
        {
            var sut = new ScheduledTimer();

            sut.StartingAt(DateTime.Now.AddMilliseconds(100));

            // Becuase of the nature of time, give the interval a second of leeway
            Assert.That(sut.TimerObject.Interval, Is.InRange(100d, 200d));

            sut.Every(TimeSpan.FromMilliseconds(200));

            // Becuase of the nature of time, give the interval a second of leeway
            Assert.That(sut.TimerObject.Interval, Is.InRange(100d, 200d));

            sut.Begin();

            Thread.Sleep(300);

            Assert.That(sut.TimerObject.Interval, Is.EqualTo(200));
        }
示例#2
0
        public void SettingStartTimeShouldOverwriteIntervalPreviouslySet()
        {
            var sut = new ScheduledTimer();

            sut.Every(new TimeSpan(0, 0, 0, 1));

            Assert.That(sut.TimerObject.Interval, Is.EqualTo(1000));

            sut.StartingAt(DateTime.Now.AddSeconds(3));

            // Becuase of the nature of time, give the interval a second of leeway
            Assert.That(sut.TimerObject.Interval, Is.InRange(2900d, 3000d));
        }