private static ExpectedTrace RemovePlaceholderTrace(ExpectedTrace expectedTrace) { ExpectedTrace modifiedTrace = new ExpectedTrace(expectedTrace); int count = modifiedTrace.Trace.Steps.Count; for (int i = 0; i < count; i++) { WorkflowTraceStep workflowTraceStep = expectedTrace.Trace.Steps[i]; if (workflowTraceStep is IPlaceholderTraceProvider) { modifiedTrace.Trace.Steps[i] = ((IPlaceholderTraceProvider)workflowTraceStep).GetPlaceholderTrace(); continue; } else if (workflowTraceStep is TraceGroup) { ExpectedTrace tempExpectedTrace = new ExpectedTrace { Trace = TraceGroup.GetNewTraceGroup((TraceGroup)workflowTraceStep) }; modifiedTrace.Trace.Steps.RemoveAt(i); ExpectedTrace cleanedUpExpectedTrace = TrackingFilter.RemovePlaceholderTrace(tempExpectedTrace); //add only if it is non-empty modifiedTrace.Trace.Steps.Insert(i, cleanedUpExpectedTrace.Trace); } } return(modifiedTrace); }
private static ExpectedTrace RemoveUserTrace(ExpectedTrace expectedTrace) { ExpectedTrace modifiedTrace = new ExpectedTrace(expectedTrace); int count = modifiedTrace.Trace.Steps.Count; int removedCount = 0; for (int i = 0; i < count; i++) { WorkflowTraceStep workflowTraceStep = expectedTrace.Trace.Steps[i]; if (workflowTraceStep is UserTrace) { modifiedTrace.Trace.Steps.Remove(workflowTraceStep); removedCount++; continue; } else if (workflowTraceStep is TraceGroup) { ExpectedTrace tempExpectedTrace = new ExpectedTrace { Trace = TraceGroup.GetNewTraceGroup((TraceGroup)workflowTraceStep) }; //take into account for activities already removed. modifiedTrace.Trace.Steps.RemoveAt(i - removedCount); ExpectedTrace cleanedUpExpectedTrace = TrackingFilter.RemoveUserTrace(tempExpectedTrace); //add only if it is non-empty if ((cleanedUpExpectedTrace != null) && (cleanedUpExpectedTrace.Trace != null) && (cleanedUpExpectedTrace.Trace.Steps != null) && (cleanedUpExpectedTrace.Trace.Steps.Count != 0) ) { modifiedTrace.Trace.Steps.Insert(i - removedCount, cleanedUpExpectedTrace.Trace); } else { removedCount++; } } } return(modifiedTrace); }