private void AssertIsValid(ITextToSchedule tts, string expression) { Assert.IsTrue(tts.IsValid(expression), "\"{0}\" is not a valid expression.", expression); Assert.IsTrue(tts.Parse(expression) != null, "\"{0}\" IS a valid expression, but it does not return any results .", expression); Assert.IsTrue(tts.Parse(expression).RegisterGroups.Count > 0, "\"{0}\" IS a valid expression, but it does not return any results .", expression); }
static void Main(string[] args) { //create and parse the text into a TextToScheduleResults string scheduleText = "every 2 seconds"; Console.WriteLine("Running schedule of \"{0}\"", scheduleText); ITextToSchedule parser = TextToScheduleFactory.CreateEnglishParser(); TextToScheduleResults results = parser.Parse(scheduleText); //create & start the scheduler ISchedulerFactory factory = new StdSchedulerFactory(); IScheduler sched = factory.GetScheduler(); sched.Start(); //create a job detail IJobDetail job = JobBuilder.Create <SampleJob>().Build(); //schedule job results.ScheduleWithJob(sched, job); }