Execute() public method

public Execute ( ) : void
return void
示例#1
0
        public void JobExecutionShouldBeLogged()
        {
            var logger = new LoggerMock();
            var job = new Job { LoggerDelegate = logger };

            job.Execute();

            logger.IsLogged(LogActivity.JobStarted, job.ItemDescription).ShouldBeTrue("Job start should be logged.");
            logger.IsLogged(LogActivity.JobFinished, job.ItemDescription).ShouldBeTrue("Job finish should be logged.");
        }
        public void StoppedJobShouldBeLoggedAsCancelled()
        {
            var logger = new LoggerMock();
            var job = new Job { LoggerDelegate = logger, ProgressDelegate = this };

            job.JobTasks.Add(new JobTaskToSucceed());
            job.JobTasks.Add(new JobTaskToSucceed());
            job.Execute();

            logger.IsLogged(LogActivity.JobCancelled, job.ItemDescription);
        }
        public void FailedJobLogShouldShowUndoTasksAreExecuted()
        {
            var logger = new LoggerMock();

            var job = new Job { LoggerDelegate = logger };
            job.JobTasks.Add(new JobTaskToFailWithoutUndo());

            try
            {
                job.Execute();
            }
            catch (Exception)
            {
                job.Undo();

                logger.IsLogged(LogActivity.SkippingUndoNotDefined, job.JobTasks[0]).ShouldBeTrue("JobTask without undo instruction should log as skipping undo not defined.");

            }
        }