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)); }
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)); }