public void SoftStop_with_longrunning_jobs()
        {
            //arrange
            var          job             = Helper.GetFakeJob().Object;
            var          job_not_started = Helper.GetLongRunningJob(TimeSpan.FromMilliseconds(5000)).Object;
            IWorkflowJob workflow        = Builder.BuildWorkflow(Helper.GetJobId())
                                           .WithOption(WhenFailure.ContinueOn, ShareContext.Parent)
                                           .AddJob(job)
                                           .ThenAdd(Helper.GetLongRunningJob(TimeSpan.FromSeconds(1)).Object)
                                           .ThenAdd(Helper.GetLongRunningJob(TimeSpan.FromSeconds(1)).Object)
                                           .ThenAdd(Helper.GetLongRunningJob(TimeSpan.FromSeconds(1)).Object)
                                           .ThenAdd(Helper.GetLongRunningJob(TimeSpan.FromSeconds(1)).Object)
                                           .ThenAdd(job_not_started)
                                           .NothingElse().Create() as IWorkflowJob;

            //act
            IWorkflowRunner runner = new SequentialRunner().Start(workflow);

            runner.SoftStop();
            Thread.Sleep(2500);
            var actual = runner.GetStatus(job.Id);

            //assert
            Assert.NotNull(runner);
            Assert.NotNull(runner.Current);
            Assert.Equal(workflow, runner.Current);
            Assert.True(runner.GetStatus(workflow.Id) == JobStatus.Stoped);
            Assert.True(JobStatus.Completed == actual);
            Assert.True(JobStatus.NotStarted == runner.GetStatus(job_not_started.Id));
        }
        public void GetStatus_returns_stopped()
        {
            //arrange
            IWorkflowJob workflow = Builder.BuildWorkflow(Helper.GetJobId())
                                    .WithOption(WhenFailure.StopOrExitJob, ShareContext.Parent)
                                    .AddJob(Helper.GetLongRunningJob(TimeSpan.FromSeconds(1)).Object)
                                    .ThenAdd(Helper.GetWorkflowJob(noOfJobs: 5))
                                    .ThenAdd(Helper.GetFakeJob().Object)
                                    .ThenAdd(Helper.GetLongRunningJob(TimeSpan.FromSeconds(1)).Object)
                                    .ThenAdd(Helper.GetLongRunningJob(TimeSpan.FromSeconds(1)).Object)
                                    .ThenAdd(Helper.GetLongRunningJob(TimeSpan.FromSeconds(1)).Object)
                                    .ThenAdd(Helper.GetLongRunningJob(TimeSpan.FromSeconds(1)).Object)
                                    .ThenAdd(Helper.GetLongRunningJob(TimeSpan.FromSeconds(1)).Object)
                                    .ThenAdd(Helper.GetLongRunningJob(TimeSpan.FromMilliseconds(10000)).Object)
                                    .ThenAdd(Helper.GetFakeJob().Object)
                                    .NothingElse().Create() as IWorkflowJob;

            //act
            IWorkflowRunner runner = new SequentialRunner().Start(workflow);

            runner.SoftStop();
            Thread.Sleep(2500);
            var actual = runner.GetStatus(workflow.Id);

            //assert
            Assert.NotNull(runner);
            Assert.NotNull(runner.Current);
            Assert.Equal(workflow, runner.Current);
            Assert.True(actual == JobStatus.Stoped);
        }