Exemplo n.º 1
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.");
        }
Exemplo n.º 2
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.");
        }
Exemplo 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.");
        }