protected override void GetActivitySpecificTrace(TraceGroup traceGroup) { UnorderedTraces parallelTraceGroup = new UnorderedTraces(); if (this.HintIterationCount < 0 && _values == null) { return; } if (this.HintIterationCount < 0 && _values != null) { this.HintIterationCount = _values.Count <T>(); } if (_valuesActivity != null) { Outcome conditionOutcome = _valuesActivity.GetTrace(traceGroup); if (conditionOutcome.DefaultPropogationState != OutcomeState.Completed) { // propogate the unknown outcome upwards this.CurrentOutcome = conditionOutcome; } } if (this.Body != null) { Outcome outc; for (int i = 1; i < _values.Count <T>() + 1; i++) { OrderedTraces orderedTraceGroup = new OrderedTraces(); if (HintIterationCount < i) { TestDummyTraceActivity tdt = new TestDummyTraceActivity(Body.DisplayName) { ExpectedOutcome = Outcome.Canceled }; tdt.GetTrace(orderedTraceGroup); } else { outc = this.Body.GetTrace(orderedTraceGroup); if (this.ProductParallelForEach.CompletionCondition != null && outc.DefaultPropogationState != OutcomeState.Canceled) { TestDummyTraceActivity condition = new TestDummyTraceActivity(this.ProductParallelForEach.CompletionCondition, ConditionOutcome); CurrentOutcome = condition.GetTrace(orderedTraceGroup); } if (outc.DefaultPropogationState != OutcomeState.Completed) { CurrentOutcome = outc; } } parallelTraceGroup.Steps.Add(orderedTraceGroup); } traceGroup.Steps.Add(parallelTraceGroup); } }
protected override void GetActivitySpecificTrace(TraceGroup traceGroup) { // Parallel is a collection of unordered branches UnorderedTraces parallelTraceGroup = new UnorderedTraces(); bool oneCompleted = false; int index = 0; foreach (TestActivity branch in _branches) { // Each Branch is Ordered with respect to itself (like normal) OrderedTraces branchTraceGroup = new OrderedTraces(); if (_numberOfBranchesExecution == index) { // so if we have gone past the hint if (branch.ExpectedOutcome.DefaultPropogationState == OutcomeState.Completed) { TestDummyTraceActivity tdt = new TestDummyTraceActivity(branch.DisplayName) { ExpectedOutcome = Outcome.Canceled }; tdt.GetTrace(branchTraceGroup); } } else { index++; Outcome bOutcome = branch.GetTrace(branchTraceGroup); if (bOutcome.DefaultPropogationState == OutcomeState.Completed) { oneCompleted = true; if (this.ProductParallel.CompletionCondition != null) { if (_expressionActivity != null) { CurrentOutcome = _expressionActivity.GetTrace(branchTraceGroup); } else { TestDummyTraceActivity tdt = new TestDummyTraceActivity(this.ProductParallel.CompletionCondition, Outcome.Completed); CurrentOutcome = tdt.GetTrace(branchTraceGroup); } } } else if (CurrentOutcome.IsOverrideable) { CurrentOutcome = bOutcome; } } parallelTraceGroup.Steps.Add(branchTraceGroup); } // If there's at least one good branch and the CompletionCondition is true, we probably succeeded if (oneCompleted && _completionCondition) { this.CurrentOutcome = Outcome.Completed; } traceGroup.Steps.Add(parallelTraceGroup); }