public void CheckReturnsNullIfWithinPeriod() { var clockMock = new Mock<IClock>(); clockMock.Setup(c => c.Now).Returns(() => DateTime.Now); var trigger = new Interval(TimeSpan.FromMinutes(5)) { Clock = clockMock.Object }; trigger.Reset(); var actual = trigger.Check(); Assert.IsNull(actual); }
public void CheckReturnsIntegrationRequestIfBeyondPeriod() { var clockMock = new Mock<IClock>(); var time = DateTime.Now; clockMock.Setup(c => c.Now).Returns(() => { time = time.AddMinutes(6); return time; }); var trigger = new Interval(TimeSpan.FromMinutes(5)) { Clock = clockMock.Object }; trigger.Reset(); var now = DateTime.Now; var actual = trigger.Check(); Assert.IsNotNull(actual); Assert.AreEqual("Interval", actual.SourceTrigger); Assert.IsTrue(actual.Time >= now && actual.Time <= DateTime.Now); }