Beispiel #1
0
        public static WorkflowJob GetWorkflowJob(JobId id = null, WhenFailure ifFailure = WhenFailure.ContinueOn, ShareContext share = ShareContext.Parent, int noOfJobs = 0, JobStatus status = JobStatus.Completed, bool longProcess = false)
        {
            if (id == null)
            {
                id = GetJobId();
            }

            var context = new Mock <IJobContext>();

            context.Setup(c => c.ParentJobId).Returns(id);

            var rtn = new WorkflowJob(id, context.Object, ifFailure, share);

            for (int i = 0; i < noOfJobs; i++)
            {
                rtn.AddJob(
                    longProcess?
                    GetLongRunningJob(
                        TimeSpan.FromMilliseconds(500),
                        null, status)
                    .Object :
                    GetFakeJob(null, status)
                    .Object);
            }

            return(rtn);
        }
Beispiel #2
0
        public static WorkflowJob GetNestedWorkflowWithRandomStatus(TimeSpan timeToRun, int noOfJobs = 2)
        {
            JobId id = GetJobId();

            var context = new Mock <IJobContext>();

            context.Setup(c => c.ParentJobId).Returns(id);

            var rtn = new WorkflowJob(id, context.Object, WhenFailure.ContinueOn, ShareContext.Parent);
            var rn  = new Random();

            for (int i = 0; i < noOfJobs; i++)
            {
                var n = rn.Next(10);
                n = n == 0 ? 2 : n;
                rtn.AddJob(GetWorkflowJob(noOfJobs: n, longProcess: true, status: n % 2 == 0 ? JobStatus.Completed: JobStatus.CompletedWithError));
            }

            return(rtn);
        }