public void Execute_JobClassProvided_ShouldScheduleNewJob()
        {
            const string groupName = "Group";
            const string jobName   = "Job";

            var stub = new SchedulerHostStub(new[] { typeof(System.Object) });

            var command = new AddTriggerCommand(() => stub.Value, new RegisteredInputType[0]);

            AddTriggerOutput result = (AddTriggerOutput)command.Execute(new AddTriggerInput
            {
                Group       = groupName,
                Job         = jobName,
                JobClass    = typeof(System.Object).ToString(),
                Name        = "Trigger",
                TriggerType = "Simple"
            });

            result.AssertSuccessfull();

            GroupStub   group   = stub.GetSingleGroup();
            JobStub     job     = group.GetSingleJob();
            TriggerStub trigger = job.GetSingleTrigger();

            Assert.That(group.Name, Is.EqualTo(groupName));
            Assert.That(job.Name, Is.EqualTo(jobName));
            Assert.That(job.JobType, Is.EqualTo(typeof(System.Object)));
            Assert.That(trigger.Name, Is.EqualTo("Trigger"));
        }
        public void Execute_NoJobClass_ShouldAddTriggerToExistingJob()
        {
            const string groupName = "Group";
            const string jobName   = "Job";

            var stub = new SchedulerHostStub();

            var command = new AddTriggerCommand(() => stub.Value, new RegisteredInputType[0]);

            AddTriggerOutput result = (AddTriggerOutput)command.Execute(new AddTriggerInput
            {
                Group       = groupName,
                Job         = jobName,
                Name        = "Trigger",
                TriggerType = "Simple"
            });

            result.AssertSuccessfull();

            GroupStub   group   = stub.GetSingleGroup();
            JobStub     job     = group.GetSingleJob();
            TriggerStub trigger = job.GetSingleTrigger();

            Assert.That(group.Name, Is.EqualTo(groupName));
            Assert.That(job.Name, Is.EqualTo(jobName));
            Assert.That(job.JobType, Is.Null);
            Assert.That(trigger.Name, Is.EqualTo("Trigger"));
        }
        private AddTriggerOutput AssertTriggerJobDataMap(
            AddTriggerInput input,
            Action <IDictionary <string, object> > assertAction,
            params RegisteredInputType[] inputTypes)
        {
            var stub = new SchedulerHostStub();

            var command = new AddTriggerCommand(() => stub.Value, inputTypes);

            AddTriggerOutput result = (AddTriggerOutput)command.Execute(input);

            result.AssertSuccessfull();
            assertAction(stub.GetSingleGroup().GetSingleJob().GetSingleTrigger().TriggerJobData);

            return(result);
        }
        private AddTriggerOutput AssertTriggerType(AddTriggerInput input, Action <TriggerType> assertAction)
        {
            var stub = new SchedulerHostStub();

            var command = new AddTriggerCommand(() => stub.Value, new RegisteredInputType[0]);

            AddTriggerOutput result = (AddTriggerOutput)command.Execute(input);

            result.AssertSuccessfull();

            TriggerStub trigger = stub.GetSingleGroup().GetSingleJob().GetSingleTrigger();

            assertAction(trigger.Trigger);

            return(result);
        }