Example #1
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);
            }
        }
Example #2
0
        public IAsyncResult BeginProcessRequest(object message, AsyncCallback callback, object asyncState)
        {
            const string method = "BeginProcessRequest";

            var result = new StepAsyncResult(callback, asyncState, message as ComponentStepInstance);

            try
            {
                if (message is ComponentStepInstance)
                {
                    var step = (ComponentStepInstance)message;
                    if (EventSource.IsEnabled(Event.Flow))
                    {
                        EventSource.Raise(Event.Flow, method, "Running step '" + step.Name + "' in profile '" + step.ProfileInstance.Profile + "' for user " + step.ProfileInstance.User + ".", Event.Arg("Profile", step.ProfileInstance.Profile), Event.Arg("User", step.ProfileInstance.User), Event.Arg("Step", step.Name));
                    }

                    if (step.BeginMethod != null && step.EndMethod != null && step.ProfileInstance.TestFixture is IAsyncProfileTestFixture)
                    {
                        // Run it asynchronously.

                        RunAsync(result, step);
                    }
                    else
                    {
                        // Run it synchonrously.

                        Run(result, step);
                    }
                }
                else
                {
                    result.SetComplete(message, null, true);
                }
            }
            catch (Exception e)
            {
                result.SetComplete(message, e, true);
            }

            return(result);
        }