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 ResetSetsTheNextTime()
 {
     var clockMock = new Mock<IClock>(MockBehavior.Strict);
     clockMock.Setup(c => c.Today).Returns(DateTime.Today);
     clockMock.Setup(c => c.Now).Returns(DateTime.Today.AddHours(20));
     var trigger = new Schedule(TimeSpan.Parse("17:00"))
                       {
                           Clock = clockMock.Object
                       };
     trigger.Reset();
     var expected = DateTime.Today.AddDays(1).AddHours(17);
     var actual = trigger.NextTime.Value;
     DateTimeAssert.AreEqual(expected, actual, DateTimeCompare.IgnoreSeconds);
 }
 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);
 }