Beispiel #1
0
        private void Delay(ComponentStepInstance stepInstance)
        {
            const string method = "Delay";

            if (EventSource.IsEnabled(Event.MethodEnter))
            {
                EventSource.Raise(Event.MethodEnter, method);
            }

            // Create the timer first so it can be attached to the instance.

            var timer = new Timer(DelayCallback, stepInstance, Timeout.Infinite, Timeout.Infinite);

            stepInstance.Timer = timer;

            var delay = stepInstance.GetDelay();

            if (EventSource.IsEnabled(Event.Trace))
            {
                EventSource.Raise(Event.Trace, method, "Delaying before running the next step.", Event.Arg("Profile", stepInstance.ProfileInstance.Profile), Event.Arg("User", stepInstance.ProfileInstance.User), Event.Arg("Step", stepInstance.Name), Event.Arg("Delay", delay));
            }

            // Now set it.

            Interlocked.Increment(ref _outstandingRequests);
            timer.Change(delay, Timeout.Infinite);

            if (EventSource.IsEnabled(Event.MethodExit))
            {
                EventSource.Raise(Event.MethodExit, method);
            }
        }
Beispiel #2
0
        private void Run(AsyncResult result, ComponentStepInstance step)
        {
            const string method = "Run";

            try
            {
                // Run the step.

                step.StartTracking();
                step.BeginMethod.Invoke(step.ProfileInstance.TestFixture, null);
                var elapsed = step.StopTracking();

                if (EventSource.IsEnabled(Event.Flow))
                {
                    EventSource.Raise(Event.Flow, method, "Step '" + step.Name + "' in profile '" + step.ProfileInstance.Profile + "' has been run for user " + step.ProfileInstance.User + ".", Event.Arg("Profile", step.ProfileInstance.Profile), Event.Arg("User", step.ProfileInstance.User), Event.Arg("Step", step.Name), Event.Arg("elapsed", elapsed));
                }

                // Mark it as done.

                result.SetComplete(step, null, true);
            }
            catch (Exception ex)
            {
                step.TrackError();
                result.SetComplete(step, new StepFailedException(GetType(), method, step.ProfileInstance.Profile.Name, step.Name, step.ProfileInstance.User, ex), true);
            }
        }
Beispiel #3
0
        protected bool CheckCurrentIteration(out ComponentStepInstance nextStep)
        {
            // Check iterations.

            if (_currentIteration >= _iterations)
            {
                _currentIteration = 0;
                nextStep          = ParentStep == null ? null : ParentStep.GetNextStep();
                return(true);
            }

            nextStep = null;
            return(false);
        }
Beispiel #4
0
        private void RunAsync(StepAsyncResult result, ComponentStepInstance step)
        {
            const string method = "RunAsync";

            try
            {
                // Run the step.

                step.StartTracking();
                ((IAsyncProfileTestFixture)step.ProfileInstance.TestFixture).Begin(result, step.BeginMethod, step.EndMethod);
            }
            catch (Exception ex)
            {
                step.TrackError();
                result.SetComplete(step, new StepFailedException(GetType(), method, step.ProfileInstance.Profile.Name, step.Name, step.ProfileInstance.User, ex), true);
            }
        }
Beispiel #5
0
 public StepAsyncResult(AsyncCallback callback, object asyncState, ComponentStepInstance step)
     : base(callback, asyncState)
 {
     _step = step;
 }