Exemple #1
0
            internal override bool NotifyTraces(ActualTrace instanceTraces)
            {
                bool foundTrace = false;

                foreach (IActualTraceStep step in instanceTraces.Steps)
                {
                    if (step.Equals(this.traceStep))
                    {
                        foundTrace           = true;
                        _successfulTraceStep = this.traceStep;
                    }
                    else if (step.Equals(_otherTraceStep))
                    {
                        foundTrace           = true;
                        _successfulTraceStep = _otherTraceStep;
                    }

                    if (foundTrace)
                    {
                        this.manualResetEvent.Set();
                        break;
                    }
                }

                return(foundTrace);
            }
        public IActualTraceStep WaitForEitherOfTraces(IActualTraceStep trace, IActualTraceStep otherTrace)
        {
            IActualTraceStep succesfulTrace;

            TestTraceManager.Instance.WaitForEitherOfTraces(_workflowInstanceId, trace, otherTrace, out succesfulTrace);
            return(succesfulTrace);
        }
Exemple #3
0
        // <summary>
        // Find all non-validated occurences of the step
        // </summary>
        // <param name="stepLookingFor">step to look for</param>
        // <param name="startIndex">index to start search from</param>
        // <param name="mustBeAfter">look only for steps occured after time specified</param>
        // <returns>array of occurence indexes</returns>
        private static int[] FindAllEntries(IActualTraceStep stepLookingFor, int startIndex, DateTime mustBeAfter)
        {
            List <int> foundIndexes = new List <int>();

            for (int curIndex = startIndex; curIndex < TraceValidator.s_actualTrace.Steps.Count; curIndex++)
            {
                IActualTraceStep step = TraceValidator.s_actualTrace.Steps[curIndex];

                // Main step comparison
                if (step.Equals(stepLookingFor) &&
                    step.Validated == 0)
                {
                    // Remove this arbitrary 250 ms buffer to allow
                    // for the fact that this is a multithreaded system and
                    // therefore our "lastTime" isn't the actual time that the
                    // event occurred, but sometime after.
                    if (step.TimeStamp.AddMilliseconds(250) > mustBeAfter)
                    {
                        foundIndexes.Add(curIndex);
                    }
                    else
                    {
                        TraceValidator.s_errorList.Add(String.Format(
                                                           "Warning: step {0}, index {1} occured at {2}, but was expected after {3}",
                                                           stepLookingFor,
                                                           curIndex,
                                                           step.TimeStamp,
                                                           mustBeAfter));
                    }
                }
            }

            return(foundIndexes.ToArray());
        }
Exemple #4
0
 bool IActualTraceStep.Equals(IActualTraceStep trace)
 {
     return(trace is WorkflowAbortedTrace exceptionTrace &&
            exceptionTrace._instanceId == _instanceId &&
            ((_abortedReason == null || exceptionTrace._abortedReason == null) ||
             (exceptionTrace._abortedReason.GetType() == _abortedReason.GetType() &&
              exceptionTrace._abortedReason.Message == _abortedReason.Message)));
 }
        bool IActualTraceStep.Equals(IActualTraceStep trace)
        {
            if (trace is UserTrace userTrace &&
                userTrace._message == _message)
            {
                return(true);
            }

            return(false);
        }
        bool IActualTraceStep.Equals(IActualTraceStep trace)
        {
            if (trace is SynchronizeTrace synchronizeTrace &&
                synchronizeTrace.userTrace.Message == this.userTrace.Message)
            {
                return(true);
            }

            return(false);
        }
Exemple #7
0
        bool IActualTraceStep.Equals(IActualTraceStep trace)
        {
            if (trace is ActivityTrace activityTrace &&
                activityTrace._activityName == _activityName &&
                activityTrace._activityStatus == _activityStatus)
            {
                return(true);
            }

            return(false);
        }
        bool IActualTraceStep.Equals(IActualTraceStep trace)
        {
            if (trace is WorkflowExceptionTrace exceptionTrace &&
                exceptionTrace._instanceName == _instanceName &&
                exceptionTrace._instanceException.ToString() == _instanceException.ToString())
            {
                return(true);
            }

            return(false);
        }
        bool IActualTraceStep.Equals(IActualTraceStep trace)
        {
            SynchronizeTrace synchronizeTrace = trace as SynchronizeTrace;

            if (synchronizeTrace != null &&
                synchronizeTrace.userTrace.Message == this.userTrace.Message)
            {
                return(true);
            }

            return(false);
        }
Exemple #10
0
        // <summary>
        // Mark step as verified
        // </summary>
        private static void MarkAsFound(int index, out DateTime timeStamp)
        {
            IActualTraceStep step = TraceValidator.s_actualTrace.Steps[index];

            if (step.Validated > 0)
            {
                throw new Exception("Internal validation failure: Attempt to mark as validated the step which already has this mark");
            }

            step.Validated = 1;
            timeStamp      = step.TimeStamp;
        }
Exemple #11
0
        bool IActualTraceStep.Equals(IActualTraceStep trace)
        {
            UserTrace userTrace = trace as UserTrace;

            if (userTrace != null &&
                userTrace._message == _message)
            {
                return(true);
            }

            return(false);
        }
Exemple #12
0
        public void Add(IActualTraceStep step)
        {
            lock (_steps)
            {
                if (step.TimeStamp == default(DateTime))
                {
                    step.TimeStamp = DateTime.Now;
                }

                _steps.Add(step);
            }
        }
        bool IActualTraceStep.Equals(IActualTraceStep trace)
        {
            if (trace is BookmarkResumptionTrace bookmarkResumptionTrace &&
                bookmarkResumptionTrace._activityName == _activityName &&
                bookmarkResumptionTrace._bookmarkName == _bookmarkName &&
                bookmarkResumptionTrace._subinstanceId == _subinstanceId)
            {
                return(true);
            }

            return(false);
        }
        bool IActualTraceStep.Equals(IActualTraceStep trace)
        {
            if (trace is WorkflowInstanceTrace instanceTrace)
            {
                if (this.InstanceStatus == instanceTrace.InstanceStatus &&
                    WorkflowInstanceTrace.CompareIdentities(instanceTrace.WorkflowDefinitionIdentity, this.WorkflowDefinitionIdentity))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #15
0
        bool IActualTraceStep.Equals(IActualTraceStep trace)
        {
            ActivityTrace activityTrace = trace as ActivityTrace;

            if (activityTrace != null &&
                activityTrace._activityName == _activityName &&
                activityTrace._activityStatus == _activityStatus)
            {
                return(true);
            }

            return(false);
        }
Exemple #16
0
        private static StepCount GetStepCount(IActualTraceStep step)
        {
            // build step string ID
            string stepId = step.GetStringId();

            if (!TraceValidator.s_stepCounts.ContainsKey(stepId))
            {
                TraceValidator.s_stepCounts.Add(stepId, new StepCount(step));
            }

            StepCount stepCount = TraceValidator.s_stepCounts[stepId];

            return(stepCount);
        }
Exemple #17
0
        public void WaitForTrace(Guid workflowInstanceId, IActualTraceStep trace, int count)
        {
            ManualResetEvent mre = new ManualResetEvent(false);

            Subscription subscription = new Subscription(trace, count, mre);

            AddSubscription(workflowInstanceId, subscription);

            if (!mre.WaitOne(TimeSpan.FromSeconds(TestTraceManager.MaximumNumberOfSecondsToWaitForATrace)))
            {
                throw new TimeoutException(string.Format("Waited for {0} seconds in WaitForTrace without getting the expeced trace of {1}",
                                                         TestTraceManager.MaximumNumberOfSecondsToWaitForATrace, trace.ToString()));
            }
        }
Exemple #18
0
        public void WaitForEitherOfTraces(Guid workflowInstanceId, IActualTraceStep trace, IActualTraceStep otherTrace, out IActualTraceStep succesfulTrace)
        {
            ManualResetEvent mre = new ManualResetEvent(false);

            ORSubscription subscription = new ORSubscription(trace, otherTrace, mre);

            AddSubscription(workflowInstanceId, subscription);

            if (!mre.WaitOne(TimeSpan.FromSeconds(TestTraceManager.MaximumNumberOfSecondsToWaitForATrace)))
            {
                throw new TimeoutException(string.Format("Waited for {0} seconds in WaitForEitherOfTraces without getting either trace of {1} or {2}",
                                                         TestTraceManager.MaximumNumberOfSecondsToWaitForATrace, trace.ToString(), otherTrace.ToString()));
            }

            succesfulTrace = subscription.SuccessfulTraceStep;
        }
Exemple #19
0
        public void AddTrace(Guid instanceId, IActualTraceStep trace)
        {
            if (trace == null)
            {
                throw new ArgumentNullException("trace");
            }

            //Log.TraceInternal("[TestTraceManager] " + instanceId + " - " + trace.ToString());

            lock (_thisLock)
            {
                ActualTrace instanceTraces = GetInstanceActualTrace(instanceId);
                instanceTraces.Add(trace);
                CheckSubscriptions(instanceId, instanceTraces);
            }
        }
Exemple #20
0
        /// <summary>
        /// Depending on the value of userVerifyTypes, either verify only types on the verify list
        /// or verify only types not in the ignore list
        /// </summary>
        /// <param name="step">Step to check</param>
        internal bool CanBeIgnored(IActualTraceStep step)
        {
            // If this is a workflow instance trace, and the instance is in the ignored collection, ignore it
            if (step is WorkflowInstanceTrace && _ignoredStates.Contains(((WorkflowInstanceTrace)step).InstanceStatus))
            {
                return(true);
            }

            if (_useVerifyTypes)
            {
                return(!_verifyTypes.Contains(step.GetType().FullName));
            }
            else
            {
                return(_ignoreTypes.Contains(step.GetType().FullName));
            }
        }
Exemple #21
0
        public override bool IsAllowed(IActualTraceStep actualTrace)
        {
            ActivityTrace at = actualTrace as ActivityTrace;

            return(at == null || !this.DisplayNames.Contains(at.ActivityName));
        }
Exemple #22
0
 private static void AddActualStepCount(IActualTraceStep step)
 {
     TraceValidator.GetStepCount(step).actualTraceCount++;
 }
Exemple #23
0
 // Actual Trace Filter
 public abstract bool IsAllowed(IActualTraceStep actualTrace);
Exemple #24
0
 private static void AddExpectedOptStepCount(IActualTraceStep step)
 {
     TraceValidator.GetStepCount(step).expectedOptCount++;
 }
 public void WaitForEitherOfTraces(IActualTraceStep trace, IActualTraceStep otherTrace, out IActualTraceStep successfulTrace)
 {
     successfulTrace = WaitForEitherOfTraces(trace, otherTrace);
 }
 public void WaitForTrace(IActualTraceStep trace, int numOccurences)
 {
     TestTraceManager.Instance.WaitForTrace(_workflowInstanceId, trace, numOccurences);
 }
 public void WaitForTrace(IActualTraceStep trace)
 {
     WaitForTrace(trace, 1);
 }
Exemple #28
0
 public StepCount(IActualTraceStep step)
 {
     this.step = step;
 }
Exemple #29
0
 public ORSubscription(IActualTraceStep traceStep, IActualTraceStep otherTraceStep, ManualResetEvent mre)
     : base(traceStep, 1, mre)
 {
     _otherTraceStep = otherTraceStep;
 }
Exemple #30
0
 public Subscription(IActualTraceStep traceStep, int numOccurance, ManualResetEvent mre)
 {
     this.traceStep        = traceStep;
     this.count            = numOccurance;
     this.manualResetEvent = mre;
 }