Ejemplo n.º 1
0
 public void TestRunningToCloseToFailedTaskAppErrorScenario()
 {
     var taskState = new TaskStateMachine();
     taskState.MoveNext(TaskStateEvent.SubmittedTask);
     taskState.MoveNext(TaskStateEvent.RunningTask);
     taskState.MoveNext(TaskStateEvent.WaitingTaskToClose);
     Assert.True(taskState.MoveNext(TaskStateEvent.FailedTaskAppError).Equals(TaskState.TaskClosedByDriver), "Failed to move from WaitingTaskToClose to TaskClosedByDriver state with FailedTaskAppError.");
 }
Ejemplo n.º 2
0
 public void TestRunningToCloseScenario()
 {
     var taskState = new TaskStateMachine();
     taskState.MoveNext(TaskStateEvent.SubmittedTask);
     taskState.MoveNext(TaskStateEvent.RunningTask);
     Assert.True(taskState.MoveNext(TaskStateEvent.WaitingTaskToClose).Equals(TaskState.TaskWaitingForClose), "Failed to move from RunningTask to TaskWaitingForClose state.");
     Assert.False(taskState.IsFinalState(), "TaskWaitingForClose should not be a final state.");
     Assert.True(taskState.MoveNext(TaskStateEvent.ClosedTask).Equals(TaskState.TaskClosedByDriver), "Failed to move from TaskWaitingForClose to TaskClosedByDriver state.");
     Assert.True(taskState.IsFinalState(), "TaskClosedByDriver should be a final state.");
 }
Ejemplo n.º 3
0
 public void TestNewToCompleteScenario()
 {
     var taskState = new TaskStateMachine();
     Assert.True(taskState.CurrentState.Equals(TaskState.TaskNew), "State of newly created task should be TaskNew");
     Assert.False(taskState.IsFinalState(), "TaskNew should not be a final state.");
     Assert.True(taskState.MoveNext(TaskStateEvent.SubmittedTask).Equals(TaskState.TaskSubmitted), "Failed to move from TaskNew to TaskSubmitted state.");
     Assert.False(taskState.IsFinalState(), "TaskSubmitted should not be a final state.");
     Assert.True(taskState.MoveNext(TaskStateEvent.RunningTask).Equals(TaskState.TaskRunning), "Failed to move from TaskSubmitted to TaskRunning state.");
     Assert.False(taskState.IsFinalState(), "TaskRunning should not be a final state.");
     Assert.True(taskState.MoveNext(TaskStateEvent.CompletedTask).Equals(TaskState.TaskCompleted), "Failed to move from TaskRunning to TaskCompleted state.");
     Assert.True(taskState.IsFinalState(), "TaskCompleted should be a final state.");
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Construct a TaskInfo that wraps task state, task configuration, and active context for submitting the task 
 /// </summary>
 /// <param name="taskState"></param>
 /// <param name="config"></param>
 /// <param name="context"></param>
 internal TaskInfo(TaskStateMachine taskState, IConfiguration config, IActiveContext context)
 {
     _taskState = taskState;
     _taskConfiguration = config;
     _activeContext = context;
 }
Ejemplo n.º 5
0
        public void TestFromFailToNotAllowedTransitions()
        {
            var taskState = new TaskStateMachine();
            taskState.MoveNext(TaskStateEvent.SubmittedTask);
            taskState.MoveNext(TaskStateEvent.RunningTask);

            taskState.MoveNext(TaskStateEvent.FailedTaskEvaluatorError);
            Assert.True(taskState.CurrentState.Equals(TaskState.TaskFailedByEvaluatorFailure), "Failed to move to TaskFailedByEvaluatorFailure state.");

            Action moveNext = () => taskState.MoveNext(TaskStateEvent.RunningTask);
            Assert.Throws<TaskStateTransitionException>(moveNext);

            moveNext = () => taskState.MoveNext(TaskStateEvent.ClosedTask);
            Assert.Throws<TaskStateTransitionException>(moveNext);

            moveNext = () => taskState.MoveNext(TaskStateEvent.CompletedTask);
            Assert.Throws<TaskStateTransitionException>(moveNext);

            moveNext = () => taskState.MoveNext(TaskStateEvent.SubmittedTask);
            Assert.Throws<TaskStateTransitionException>(moveNext);

            moveNext = () => taskState.MoveNext(TaskStateEvent.WaitingTaskToClose);
            Assert.Throws<TaskStateTransitionException>(moveNext);

            moveNext = () => taskState.MoveNext(TaskStateEvent.FailedTaskAppError);
            Assert.Throws<TaskStateTransitionException>(moveNext);

            moveNext = () => taskState.MoveNext(TaskStateEvent.FailedTaskCommunicationError);
            Assert.Throws<TaskStateTransitionException>(moveNext);

            moveNext = () => taskState.MoveNext(TaskStateEvent.FailedTaskSystemError);
            Assert.Throws<TaskStateTransitionException>(moveNext); 
        }
Ejemplo n.º 6
0
        public void TestFromRunningToNotAllowedTransitions()
        {
            var taskState = new TaskStateMachine();
            taskState.MoveNext(TaskStateEvent.SubmittedTask);
            taskState.MoveNext(TaskStateEvent.RunningTask);

            Action moveNext = () => taskState.MoveNext(TaskStateEvent.SubmittedTask);
            Assert.Throws<TaskStateTransitionException>(moveNext);

            moveNext = () => taskState.MoveNext(TaskStateEvent.ClosedTask);
            Assert.Throws<TaskStateTransitionException>(moveNext);
        }
Ejemplo n.º 7
0
 public void TestRunningToFailBySystemThenByEvaluatorScenario()
 {
     var taskState = new TaskStateMachine();
     taskState.MoveNext(TaskStateEvent.SubmittedTask);
     taskState.MoveNext(TaskStateEvent.RunningTask);
     Assert.True(taskState.MoveNext(TaskStateEvent.FailedTaskSystemError).Equals(TaskState.TaskFailedBySystemError), "Failed to move from RunningTask to TaskFailedBySystemError state with FailedTaskSystemError.");
     Assert.True(taskState.IsFinalState(), "TaskFailedByGroupCommunication should be a final state.");
     Assert.True(taskState.MoveNext(TaskStateEvent.FailedTaskEvaluatorError).Equals(TaskState.TaskFailedByEvaluatorFailure), "Failed to move from TaskFailedBySystemError to TaskFailedByEvaluatorFailure state with FailedTaskEvaluatorError.");
     Assert.True(taskState.IsFinalState(), "TaskFailedByEvaluatorFailure should be a final state.");
 }
Ejemplo n.º 8
0
 public void TestRunningToWaitingTaskToCloseToComplete()
 {
     var taskState = new TaskStateMachine();
     taskState.MoveNext(TaskStateEvent.SubmittedTask);
     taskState.MoveNext(TaskStateEvent.RunningTask);
     taskState.MoveNext(TaskStateEvent.WaitingTaskToClose);
     taskState.MoveNext(TaskStateEvent.CompletedTask);
     Assert.Equal(TaskState.TaskClosedByDriver, taskState.CurrentState);
 }