Пример #1
0
        public ActualTrace(ActualTrace actualTrace)
        {
            lock (actualTrace.Steps)
            {
                foreach (IActualTraceStep step in actualTrace.Steps)
                {
                    if (step is ActivityTrace activityTrace)
                    {
                        this.Steps.Add(new ActivityTrace(activityTrace));
                        continue;
                    }

                    //WorkflowInstanceUpdatedTrace workflowInstanceUpdatedTrace = step as WorkflowInstanceUpdatedTrace;
                    //if (workflowInstanceUpdatedTrace != null)
                    //{
                    //    this.Steps.Add(new WorkflowInstanceUpdatedTrace(workflowInstanceUpdatedTrace.InstanceName, workflowInstanceUpdatedTrace.OriginalWorkflowIdentity, workflowInstanceUpdatedTrace.WorkflowDefinitionIdentity, workflowInstanceUpdatedTrace.InstanceStatus));
                    //    continue;
                    //}

                    if (step is WorkflowInstanceTrace workflowInstanceTrace)
                    {
                        this.Steps.Add(new WorkflowInstanceTrace(workflowInstanceTrace.InstanceName, workflowInstanceTrace.WorkflowDefinitionIdentity, workflowInstanceTrace.InstanceStatus));
                        continue;
                    }

                    if (step is UserTrace userTrace)
                    {
                        this.Steps.Add(new UserTrace(userTrace.InstanceId, userTrace.ActivityParent, userTrace.Message));
                        continue;
                    }

                    if (step is BookmarkResumptionTrace bookmarkResumptionTrace)
                    {
                        this.Steps.Add(new BookmarkResumptionTrace(bookmarkResumptionTrace.BookmarkName, bookmarkResumptionTrace.SubinstanceId,
                                                                   bookmarkResumptionTrace.ActivityName));
                        continue;
                    }

                    if (step is SynchronizeTrace synchronizeTrace)
                    {
                        this.Steps.Add(new SynchronizeTrace(synchronizeTrace.userTrace.InstanceId,
                                                            synchronizeTrace.userTrace.Message));
                        continue;
                    }

                    if (step is WorkflowExceptionTrace weTrace)
                    {
                        this.Steps.Add(new WorkflowExceptionTrace(weTrace.InstanceName, weTrace.InstanceException));
                        continue;
                    }

                    if (step is WorkflowAbortedTrace wasTrace)
                    {
                        this.Steps.Add(new WorkflowAbortedTrace(wasTrace.InstanceId, wasTrace.AbortedReason));
                        continue;
                    }
                }
            }
        }
Пример #2
0
        public ActualTrace FilterActualTrace(ActualTrace at)
        {
            // Actual trace is much easier, since it will always be a collection of ordered traces
            ActualTrace actualTrace = new ActualTrace();

            lock (at.Steps)
            {
                foreach (IActualTraceStep step in at.Steps)
                {
                    if (IsAllowed(step))
                    {
                        actualTrace.Add(step);
                    }
                }
            }
            return(actualTrace);
        }
Пример #3
0
        /// <summary>
        /// Constructor
        /// </summary>
        public static void Validate(ActualTrace actualTrace, ExpectedTrace expectedTrace, bool traceTracking)
        {
            TraceValidator.s_actualTrace   = actualTrace;
            TraceValidator.s_expectedTrace = expectedTrace;

            TraceValidator.s_errorList  = new List <string>();
            TraceValidator.s_stepCounts = new Dictionary <string, StepCount>();

            TestTraceManager.OptionalLogTrace("[TraceValidator]Unfiltered expected trace:\n{0}", expectedTrace.ToString());
            TestTraceManager.OptionalLogTrace("[TraceValidator]Unfiltered actual trace:\n{0}", actualTrace.ToString());

            TraceValidator.NormalizeExpectedTrace(expectedTrace.Trace);
            TraceValidator.RemoveIgnorableSteps(expectedTrace.Trace);
            TraceValidator.PrepareExpectedTrace(expectedTrace.Trace, false, null, -1);

            TraceValidator.PrepareActualTrace();

            if (traceTracking)
            {
                //Log.TraceInternal("[TraceValidator]Filtered expected trace:\n{0}", expectedTrace.ToString());
                //Log.TraceInternal("[TraceValidator]Filtered actual trace:\n{0}", actualTrace.ToString());
                //Log.TraceInternal("[TraceValidator]Doing count validation...");
            }

            TraceValidator.CheckStepCounts();
            TraceValidator.CheckErrors();

            if (traceTracking)
            {
                //Log.TraceInternal("[TraceValidator]Validating...");
            }
            TraceValidator.ValidateFirst(expectedTrace.Trace, 0);
            TraceValidator.CheckErrors();

            if (traceTracking)
            {
                //Log.TraceInternal("[TraceValidator]ExpectedTrace: Validation complete.");
            }
        }
Пример #4
0
        public void Validate(ExpectedTrace expectedTrace, bool logTraces)
        {
            lock (_steps)
            {
                if (expectedTrace.SortBeforeVerification)
                {
                    // copy the expected trace, remove activity traces and verify workflow instnace traces
                    ExpectedTrace etrace = new ExpectedTrace(expectedTrace);
                    ActualTrace   atrace = new ActualTrace(this);
                    etrace.AddIgnoreTypes(typeof(ActivityTrace), typeof(UserTrace));
                    TraceValidator.Validate(atrace, etrace, logTraces);

                    // now verify the activity traces, after they have been ordered
                    expectedTrace.AddIgnoreTypes(typeof(WorkflowInstanceTrace));
                    expectedTrace.AddIgnoreTypes(typeof(UserTrace));
                    this.OrderTraces();
                    TraceValidator.Validate(this, expectedTrace);
                }
                else
                {
                    TraceValidator.Validate(this, expectedTrace, logTraces);
                }
            }
        }
Пример #5
0
 public static void Validate(ActualTrace actualTrace, ExpectedTrace expectedTrace)
 {
     Validate(actualTrace, expectedTrace, true);
 }