public void GetHoursAndMinutes_ForNowKeyword_ReturnsCurrentTimeInHoursAndMinutesComponents() { var result = ScheduleStringHelper.GetHoursAndMinutes("now"); Assert.That(DateTime.Now.Hour == result.Item1); Assert.That(DateTime.Now.Minute == result.Item2); }
public void GetHoursAndMinutes_ForTime_ReturnsTimeInHoursAndMinutesComponents() { var result = ScheduleStringHelper.GetHoursAndMinutes("13:42"); Assert.That(result.Item1 == 13); Assert.That(result.Item2 == 42); }
public void GetHoursAndMinutes_ForNowPlusOffsetKeyword_ReturnsCurrentTimePlusOffsetInHoursAndMinutesComponents() { var result = ScheduleStringHelper.GetHoursAndMinutes("now+2"); var nowPlusOffset = DateTime.Now.AddMinutes(2); Assert.That(nowPlusOffset.Hour == result.Item1); Assert.That(nowPlusOffset.Minute == result.Item2); }
private static ITrigger CreateTriggerForSpecificRunTime(string triggerName, string runAtTime, string runOnDays, string excludeCalendar, string targetTimeZone) { ITrigger trigger = null; TimeZoneInfo timezone = TimeZoneInfo.Local; if (!string.IsNullOrEmpty(targetTimeZone)) { timezone = TimeZoneInfo.FindSystemTimeZoneById(targetTimeZone); } if (!string.IsNullOrEmpty(runOnDays)) { var daysOfWeek = ScheduleStringHelper.GetDaysOfWeekToRunOn(runOnDays); var runAtTuple = ScheduleStringHelper.GetHoursAndMinutes(runAtTime); trigger = TriggerBuilder.Create() .WithIdentity(triggerName) .WithDescription($"Run at: {runAtTime}, run days: {runOnDays}, exclusion calendar: {excludeCalendar}") .WithSchedule(CronScheduleBuilder.AtHourAndMinuteOnGivenDaysOfWeek(runAtTuple.Item1, runAtTuple.Item2, daysOfWeek) .InTimeZone(timezone)) .ModifiedByCalendar(excludeCalendar) .StartNow() .Build(); } //else if (!string.IsNullOrEmpty(runCalendar)) //{ // trigger = TriggerBuilder.Create() // .WithIdentity(string.Format("Trigger_for_{0}", job.Key)) // .WithDescription(string.Format("Run at: {0}, run calendar: {1}, exclusion calendar: {2}", runAt, runCalendar, excludeCalendar)) // .WithSchedule(CronScheduleBuilder.) // .WithSchedule(CronScheduleBuilder.DailyAtHourAndMinute(hour, minute)) // .ModifiedByCalendar(runCalendar) // .StartNow() // .Build(); //} return(trigger); }