public void CheckReturnsNullIfWithinPeriod() { var clockMock = new Mock<IClock>(MockBehavior.Strict); clockMock.Setup(c => c.Today).Returns(DateTime.Today); clockMock.Setup(c => c.Now).Returns(DateTime.Today.AddHours(9)); var trigger = new Schedule(TimeSpan.Parse("17:00")) { Clock = clockMock.Object }; trigger.Reset(); var actual = trigger.Check(); Assert.IsNull(actual); }
public void CheckReturnsIntegrationRequestIfBeyondPeriod() { var clockMock = new Mock<IClock>(MockBehavior.Strict); var time = DateTime.Today.AddHours(15).AddMinutes(30); clockMock.Setup(c => c.Today).Returns(DateTime.Today); clockMock.Setup(c => c.Now).Returns(() => { time = time.AddHours(1); return time; }); var trigger = new Schedule(TimeSpan.Parse("17:00")) { Clock = clockMock.Object }; var now = DateTime.Now; trigger.Reset(); var actual = trigger.Check(); Assert.IsNotNull(actual); Assert.AreEqual("Schedule", actual.SourceTrigger); Assert.IsTrue(actual.Time >= now && actual.Time <= DateTime.Now); }