public void EnqueueShouldIncreaseCountBy1() { var job = new Job(); JobQueue.Enqueue(job); JobQueue.Count.ShouldEqual(1); }
public void GivenThatJobHasFailingTask() { _logger = new LoggerMock(); _job = new Job {LoggerDelegate = _logger}; _job.JobTasks.Add(new JobTaskToSucceed()); _job.JobTasks.Add(new JobTaskToFail()); _job.JobTasks.Add(new JobTaskToSucceed()); }
public void GivenThatJobHasFailingCommand() { _logger = new LoggerMock(); _job = new Job {LoggerDelegate = _logger}; _job.Commands.Add(new CommandToSucceed()); _job.Commands.Add(new CommandToFail()); _job.Commands.Add(new CommandToSucceed()); }
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); }
private static Dictionary<string, object> BuildParameters(Job job, string parameters) { int i = 0; var newParams = new Dictionary<string, object>(); var parameterArray = parameters.Split(','); foreach (var parameter in job.Parameters) { newParams.Add(parameter.Key, parameterArray[i]); i++; } return newParams; }
public void OneJobTaskInstanceCannotBeAddedTwice() { var job = new Job(); var successfuljobTask = new JobTaskToSucceed(); try { job.JobTasks.Add(successfuljobTask); job.JobTasks.Add(successfuljobTask); Assert.Fail("Job tasks should not allow adding the same JobTask instance twice."); } catch (DuplicateItemException e) { Debug.Print("exception caught successfully: " + e.Message); } }
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."); } }