public void Cannot_Add_Duplicate_Jobs()
        {
            var        jobName   = Guid.NewGuid().ToString();
            var        logMock   = new Mock <ILog>();
            var        schedMock = new Mock <Quartz.IScheduler>();
            IScheduler scheduler = new QuartzScheduler(logMock.Object, schedMock.Object);

            scheduler.Start();
            var package = new Entities.JobPackage()
            {
                Name           = jobName,
                Location       = new System.IO.DirectoryInfo(System.IO.Path.GetTempPath()),
                CronExpression = "0 0 12 ? * WED",
            };

            scheduler.AddJob(package);
            scheduler.AddJob(package);

            var jobNames = scheduler.GetJobs();

            Assert.Equal(1, jobNames.Count(x => x.Equals(jobName)));
        }
        public void AddScheduledJob_Should_AddJob()
        {
            var        jobName   = Guid.NewGuid().ToString();
            var        logMock   = new Mock <ILog>();
            var        schedMock = new Mock <Quartz.IScheduler>();
            IScheduler scheduler = new QuartzScheduler(logMock.Object, schedMock.Object);

            scheduler.Start();

            scheduler.AddJob(new Entities.JobPackage()
            {
                Name           = jobName,
                Location       = new System.IO.DirectoryInfo(System.IO.Path.GetTempPath()),
                CronExpression = "0 0 12 ? * WED",
            });

            var jobNames = scheduler.GetJobs();

            Assert.Equal(jobName, jobNames.First());
        }
        public void Unscheduled_Job_Should_Have_Trigger()
        {
            var jobName   = Guid.NewGuid().ToString();
            var logMock   = new Mock <ILog>();
            var schedMock = new Mock <Quartz.IScheduler>();
            var package   = new Entities.JobPackage()
            {
                Name     = jobName,
                Location = new System.IO.DirectoryInfo(System.IO.Path.GetTempPath()),
            };
            int calls = 0;

            schedMock.Setup(s => s.ScheduleJob(It.IsAny <Quartz.IJobDetail>(), It.IsAny <Quartz.ITrigger>())).Callback(() => calls++);
            IScheduler scheduler = new QuartzScheduler(logMock.Object, schedMock.Object);

            scheduler.Start();

            scheduler.AddJob(package);

            Assert.Equal(1, calls);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Calls the equivalent method on the 'proxied' <see cref="QuartzScheduler" />.
 /// </summary>
 public virtual void AddJob(IJobDetail jobDetail, bool replace)
 {
     sched.AddJob(jobDetail, replace);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Calls the equivalent method on the 'proxied' <see cref="QuartzScheduler" />.
 /// </summary>
 public virtual void AddJob(IJobDetail jobDetail, bool replace, bool storeNonDurableWhileAwaitingScheduling)
 {
     sched.AddJob(jobDetail, replace, storeNonDurableWhileAwaitingScheduling);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Calls the equivalent method on the 'proxied' <see cref="QuartzScheduler" />.
 /// </summary>
 public virtual Task AddJob(IJobDetail jobDetail, bool replace, bool storeNonDurableWhileAwaitingScheduling)
 {
     return(sched.AddJob(jobDetail, replace, storeNonDurableWhileAwaitingScheduling));
 }
Exemplo n.º 7
0
 /// <summary>
 /// Calls the equivalent method on the 'proxied' <see cref="QuartzScheduler" />,
 /// passing the <see cref="SchedulingContext" /> associated with this
 /// instance.
 /// </summary>
 public virtual void AddJob(JobDetail jobDetail, bool replace)
 {
     sched.AddJob(schedCtxt, jobDetail, replace);
 }