public void Triggered_Updates_NextAndPreviousFireTime() { // Arrange. var startTime = new DateTime(2013, 1, 16, 0, 0, 0, DateTimeKind.Local); var nextTime1 = new DateTime(2013, 1, 16, 1, 0, 0, DateTimeKind.Local); var nextTime2 = new DateTime(2013, 1, 16, 2, 0, 0, DateTimeKind.Local); var schedule = Mock.Create<ISchedule>(Behavior.CallOriginal); Mock.Arrange(() => schedule.GetNextTimeAfter(startTime)).Returns(nextTime1); Mock.Arrange(() => schedule.GetNextTimeAfter(nextTime1)).Returns(nextTime2); var target = new ESyncTrigger(schedule) { StartTimeUtc = startTime.ToUniversalTime() }; // Act. target.ComputeFirstFireTimeUtc(null); target.Triggered(null); var previousTimeUtc = target.GetPreviousFireTimeUtc(); var nextTimeUtc = target.GetNextFireTimeUtc(); // Assert. Assert.IsNotNull(previousTimeUtc); Assert.IsNotNull(nextTimeUtc); Assert.AreEqual(nextTime1, previousTimeUtc.Value.ToLocalTime()); Assert.AreEqual(nextTime2, nextTimeUtc.Value.ToLocalTime()); }
public void WhenNextFireTimeIsNotNull_GetMayFireAgain_ReturnsTrue() { // Arrange. var startTime = new DateTime(2013, 1, 16, 1, 0, 0, DateTimeKind.Local); var nextTime = new DateTime(2013, 1, 16, 2, 0, 0, DateTimeKind.Local); var schedule = Mock.Create<ISchedule>(Behavior.CallOriginal); Mock.Arrange(() => schedule.GetNextTimeAfter(startTime)).Returns(nextTime); var target = new ESyncTrigger(schedule) { StartTimeUtc = startTime.ToUniversalTime() }; // Act. target.ComputeFirstFireTimeUtc(null); // Assert. Assert.IsTrue(target.GetMayFireAgain()); }
public void ComputeFirstFireTimeUtc_Updates_NextFireTime() { // Arrange. var startTime = new DateTime(2013, 1, 16, 1, 0, 0, DateTimeKind.Local); var nextTime = new DateTime(2013, 1, 16, 2, 0, 0, DateTimeKind.Local); var schedule = Mock.Create<ISchedule>(Behavior.CallOriginal); Mock.Arrange(() => schedule.GetNextTimeAfter(startTime)).Returns(nextTime); var target = new ESyncTrigger(schedule) { StartTimeUtc = startTime.ToUniversalTime() }; // Act. var result = target.ComputeFirstFireTimeUtc(null); var nextTimeUtc = target.GetNextFireTimeUtc(); // Assert. Assert.IsNotNull(result); Assert.AreEqual(nextTime, result.Value.ToLocalTime()); Assert.IsNotNull(nextTimeUtc); Assert.AreEqual(nextTime, nextTimeUtc.Value.ToLocalTime()); }