public void ResetSetsTheNextTime()
 {
     var clockMock = new Mock<IClock>();
     clockMock.Setup(c => c.Now).Returns(() => DateTime.Now);
     var trigger = new RollUp(TimeSpan.FromMinutes(5))
                       {
                           Clock = clockMock.Object
                       };
     trigger.Reset();
     var expected = DateTime.Now.AddMinutes(5);
     var actual = trigger.NextTime.Value;
     DateTimeAssert.AreEqual(expected, actual, DateTimeCompare.IgnoreSeconds);
 }
 public void TriggerDoesNotFireInsidePeriod()
 {
     var clockMock = new Mock<IClock>();
     clockMock.Setup(c => c.Now).Returns(() => DateTime.Now);
     var inner = new TriggerStub
                     {
                         OnCheckAction = () => new IntegrationRequest("Test")
                     };
     var trigger = new RollUp(TimeSpan.FromMinutes(5))
                       {
                           InnerTrigger = inner,
                           Clock = clockMock.Object
                       };
     trigger.Reset();
     var request = trigger.Check();
     Assert.IsNull(request);
 }
 public void ValidateDetectsMissingPeriod()
 {
     var errorAdded = false;
     var trigger = new RollUp();
     var validation = new ValidationLogStub
                          {
                              OnAddErrorMessage = (m, a) =>
                                                      {
                                                          Assert.AreEqual(
                                                              "No period set - trigger will not fire",
                                                              m);
                                                          CollectionAssert.IsEmpty(a);
                                                          errorAdded = true;
                                                      }
                          };
     trigger.Validate(validation);
     Assert.IsTrue(errorAdded);
 }