public async Task GetSelectedActionsInnerAsync(List <ActionStateBase> selectedActions, TestCommandStateFilter stateFilter, TestCommandTypeFilter typeFilter) { selectedActions.Clear(); // non-terminal state if (stateFilter.HasFlag(TestCommandStateFilter.Running) || stateFilter.HasFlag(TestCommandStateFilter.RollingBack)) { await this.AddActionsMatchingFilterAsync(this.actionTable, selectedActions, stateFilter, typeFilter).ConfigureAwait(false); } // terminal state if (stateFilter.HasFlag(TestCommandStateFilter.CompletedSuccessfully) || stateFilter.HasFlag(TestCommandStateFilter.Failed) || stateFilter.HasFlag(TestCommandStateFilter.Cancelled) || stateFilter.HasFlag(TestCommandStateFilter.ForceCancelled)) { await this.AddActionsMatchingFilterAsync(this.historyTable, selectedActions, stateFilter, typeFilter).ConfigureAwait(false); } }
private static bool MatchesStateFilter(ActionStateBase actionState, TestCommandStateFilter filter) { if (filter == TestCommandStateFilter.All) { return(true); } if (filter == TestCommandStateFilter.Default) { // future use return(true); } StepStateNames stateName = actionState.StateProgress.Peek(); RollbackState rollbackState = actionState.RollbackState; if (filter.HasFlag(TestCommandStateFilter.RollingBack)) { if ((rollbackState == RollbackState.RollingBackAndWillFailAction || rollbackState == RollbackState.RollingBackForce || rollbackState == RollbackState.RollingBackDueToUserCancel) && (stateName != StepStateNames.Failed)) { return(true); } } if (filter.HasFlag(TestCommandStateFilter.Cancelled)) { // stateName == CompletedSuccessfully is possible if the command was in its last step, and finished the last step successfully // before cancellation status was read. There is no point in "cancelling" since the point is to stop execution. Since it completed successfully, // that has been achieved. However, the status should be translated here so it is not confusing to user. if ((stateName == StepStateNames.Failed || stateName == StepStateNames.CompletedSuccessfully) && (rollbackState == RollbackState.RollingBackDueToUserCancel)) { return(true); } } if (filter.HasFlag(TestCommandStateFilter.ForceCancelled)) { // See notes above in Cancelled section, which also applies here. if ((stateName == StepStateNames.Failed || stateName == StepStateNames.CompletedSuccessfully) && (rollbackState == RollbackState.RollingBackForce)) { return(true); } } switch (stateName) { case StepStateNames.IntentSaved: return(filter.HasFlag(TestCommandStateFilter.Running)); case StepStateNames.LookingUpState: return(filter.HasFlag(TestCommandStateFilter.Running)); case StepStateNames.PerformingActions: return(filter.HasFlag(TestCommandStateFilter.Running)); case StepStateNames.CompletedSuccessfully: return(filter.HasFlag(TestCommandStateFilter.CompletedSuccessfully)); case StepStateNames.Failed: return(filter.HasFlag(TestCommandStateFilter.Failed)); default: return(false); } }