public void is_time_test() { var cron_schedule = new CronSchedule("0 0 12 10 *"); Assert.IsTrue(cron_schedule.isTime(DateTime.Parse("12:00:00 am 10/12/2008"))); Assert.IsFalse(cron_schedule.isTime(DateTime.Parse("12:01:00 am 10/12/2008"))); }
public void is_time_hour_test() { var cron_schedule = new CronSchedule("* 0 * * *"); Assert.IsTrue(cron_schedule.isTime(DateTime.Parse("12:00 am"))); cron_schedule = new CronSchedule("* 0,12 * * *"); Assert.IsTrue(cron_schedule.isTime(DateTime.Parse("12:00 am"))); Assert.IsTrue(cron_schedule.isTime(DateTime.Parse("12:00 pm"))); }
public void is_time_day_of_week_test() { var cron_schedule = new CronSchedule("* * * * 0"); Assert.IsTrue(cron_schedule.isTime(DateTime.Parse("10/12/2008"))); Assert.IsFalse(cron_schedule.isTime(DateTime.Parse("10/13/2008"))); cron_schedule = new CronSchedule("* * * * */2"); Assert.IsTrue(cron_schedule.isTime(DateTime.Parse("10/14/2008"))); }
public void is_time_month_test() { var cron_schedule = new CronSchedule("* * * 1 *"); Assert.IsTrue(cron_schedule.isTime(DateTime.Parse("1/1/2008"))); cron_schedule = new CronSchedule("* * * 12 *"); Assert.IsFalse(cron_schedule.isTime(DateTime.Parse("1/1/2008"))); cron_schedule = new CronSchedule("* * * */3 *"); Assert.IsTrue(cron_schedule.isTime(DateTime.Parse("3/1/2008"))); Assert.IsTrue(cron_schedule.isTime(DateTime.Parse("6/1/2008"))); }
public void is_time_minute_test() { var cron_schedule = new CronSchedule("0 * * * *"); Assert.IsTrue(cron_schedule.isTime(DateTime.Parse("8:00 am"))); Assert.IsFalse(cron_schedule.isTime(DateTime.Parse("8:01 am"))); cron_schedule = new CronSchedule("0-10 * * * *"); Assert.IsTrue(cron_schedule.isTime(DateTime.Parse("8:00 am"))); Assert.IsTrue(cron_schedule.isTime(DateTime.Parse("8:03 am"))); cron_schedule = new CronSchedule("*/2 * * * *"); Assert.IsTrue(cron_schedule.isTime(DateTime.Parse("8:00 am"))); Assert.IsTrue(cron_schedule.isTime(DateTime.Parse("8:02 am"))); Assert.IsFalse(cron_schedule.isTime(DateTime.Parse("8:03 am"))); }
private void button1_Click_1(object sender, EventArgs e) { ICronSchedule _cron_schedule; string schedule = ""; schedule = scheduleForTest.Text; _cron_schedule = new CronSchedule(schedule); string message = _cron_schedule.isTime(DateTime.Now).ToString(); string caption = "Тест"; MessageBoxButtons buttons = MessageBoxButtons.OK; // Displays the MessageBox. MessageBox.Show(message, caption, buttons, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); }
private void button1_Click(object sender, EventArgs e) { ICronSchedule _cron_schedule; string schedule = scheduleForTest.Text; _cron_schedule = new CronSchedule(schedule); bool result = _cron_schedule.isTime(DateTime.Now); string message; if (result) { message = "Текст по текущему времени прошел."; } else { message = "Текст по текущему времени не прошел."; } string caption = "Тест расписания по Cron формату"; MessageBoxButtons buttons = MessageBoxButtons.OK; MessageBox.Show(message, caption, buttons, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); }
public void is_time_day_of_month_test() { var cron_schedule = new CronSchedule("* * 1 * *"); Assert.IsTrue(cron_schedule.isTime(DateTime.Parse("2010/08/01"))); }