コード例 #1
0
        public void CanCreateASimpleJobDefinition()
        {
            using (var session = EmbeddedRavenProvider.DocumentStore.OpenSession())
            {
                var    sut               = new JobManager(session, DataServiceTestHelper.GetEventReporter().Object, new Mock <TypeLoader>().Object);
                string assemblyName      = Guid.NewGuid().ToString();
                string className         = Guid.NewGuid().ToString();
                int    intervalMinutes   = 10;
                int    delayStartMinutes = 20;
                string jobName           = Guid.NewGuid().ToString();

                var result = sut.CreateSimpleJob(jobName, Guid.NewGuid(), assemblyName, className, intervalMinutes, delayStartMinutes);
                Assert.IsNotNull(result);
                Assert.AreNotEqual(0, result.Id);

                var dbItem = session.Load <JobDefinition>(result.Id);
                Assert.IsNotNull(dbItem);
                Assert.AreEqual(jobName, dbItem.JobName);
                Assert.AreEqual(assemblyName, dbItem.AssemblyName);
                Assert.AreEqual(className, dbItem.ClassName);
                Assert.IsInstanceOf <JobSimpleSchedule>(dbItem.Schedule);
                Assert.AreEqual(intervalMinutes, ((JobSimpleSchedule)dbItem.Schedule).IntervalMinutes);
                Assert.AreEqual(delayStartMinutes, ((JobSimpleSchedule)dbItem.Schedule).DelayStartMinutes);

                session.Delete(dbItem);
                session.SaveChanges();
            }
        }
コード例 #2
0
        public void CanEditAJobDefinition()
        {
            using (var session = EmbeddedRavenProvider.DocumentStore.OpenSession())
            {
                var    sut                = new JobManager(session, DataServiceTestHelper.GetEventReporter().Object, new Mock <TypeLoader>().Object);
                string assemblyName       = Guid.NewGuid().ToString();
                string className          = Guid.NewGuid().ToString();
                string scheduleExpression = Guid.NewGuid().ToString();
                string jobName            = Guid.NewGuid().ToString();
                var    newJob             = sut.CreateCronJob(jobName, Guid.NewGuid(), assemblyName, className, scheduleExpression);

                newJob.AssemblyName = Guid.NewGuid().ToString();
                newJob.ClassName    = Guid.NewGuid().ToString();
                ((JobCronSchedule)newJob.Schedule).CronScheduleExpression = Guid.NewGuid().ToString();
                newJob.JobName = Guid.NewGuid().ToString();

                session.SaveChanges();

                var dbItem = session.Load <JobDefinition>(newJob.Id);
                Assert.IsNotNull(dbItem);
                Assert.AreEqual(newJob.JobName, dbItem.JobName);

                session.Delete(dbItem);
                session.SaveChanges();
            }
        }
コード例 #3
0
 public void LoadJobList()
 {
     using (var session = EmbeddedRavenProvider.DocumentStore.OpenSession())
     {
         var sut  = new JobManager(session, DataServiceTestHelper.GetEventReporter().Object, new Mock <TypeLoader>().Object);
         var list = sut.LoadJobList();
         Assert.AreEqual(0, list.Count());
     }
 }