Example #1
0
 public void InitialiseSetsStateToPending()
 {
     var initialised = false;
     var task = new TaskStub
                    {
                        OnInitialiseAction = () => initialised = true
                    };
     task.Initialise();
     Assert.AreEqual(TaskState.Pending, task.State);
     Assert.IsTrue(initialised);
 }
Example #2
0
 public void CleanUpSetsStateToTerminatedIfStatusIsExecuting()
 {
     var task = new TaskStub
                    {
                        OnRunAction = c =>
                                          {
                                              // This will break the run leaving the task in
                                              // the executing state
                                              throw new Exception();
                                          }
                    };
     task.Initialise();
     var result = task.Run(null);
     Assert.Throws<Exception>(() => result.Count());
     task.CleanUp();
     Assert.AreEqual(TaskState.Terminated, task.State);
 }
Example #3
0
 public void CleanUpSetsStateToSkippedIfStatusIsPending()
 {
     var cleanedUp = false;
     var task = new TaskStub
                    {
                        OnCleanUpAction = () => cleanedUp = true
                    };
     task.Initialise();
     task.CleanUp();
     Assert.AreEqual(TaskState.Skipped, task.State);
     Assert.IsTrue(cleanedUp);
 }