Ejemplo n.º 1
0
        public void SetStartTimeShouldUpdateTheTimerIntervalAccordingly()
        {
            var sut = new ScheduledTimer();

            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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 3
0
        public void IntervalUpdatedBeforeStartShouldChangeTheIntervalUntilStartHasBeenCalled()
        {
            var sut = new ScheduledTimer();

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

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

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

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

            sut.Begin();

            Thread.Sleep(300);

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