/// <summary>
 /// Initiate the test.
 /// </summary>
 /// <param name="application"> The scripting application.</param>
 /// <param name="index"> The index.</param>
 public void TestRequestUntilIndex(ScriptingApplication application, int index)
 {
     _appClone = application.Clone();
     _startingIndex = index;
     scriptingCommand.ExecuteSessionUntilEnd(application.Clone(), index);
 }
        /// <summary>
        /// Executes a session that executes until the end index and uses a scripting file. 
        /// </summary>
        /// <param name="application"> The scripting application.</param>
        /// <param name="endIndex"> The index where the last request executes.</param>
        /// <param name="scriptingFileLocation"> The scripting file location.</param>
        //        public void ExecuteScriptedSession(ScriptingApplication application, int endIndex, string scriptingFileLocation)
        //        {
        //            _sessionScripting = application;
        //            IVsaItems    items = _engine.Items;
        //
        //            // Load the script code
        //            // NOTE: For VB, the name of the item, "Script", must match the name of the Module,
        //            //       or adding global items won't work <sigh>
        //            IVsaCodeItem codeItem = (IVsaCodeItem)items.CreateItem("Script",
        //                VsaItemType.Code,
        //                VsaItemFlag.None);
        //
        //            StreamReader reader = new StreamReader(scriptingFileLocation);
        //            codeItem.SourceText = reader.ReadToEnd();
        //            reader.Close();
        //
        //            // Add the global "This" item
        //            IVsaGlobalItem  scommand = (IVsaGlobalItem)items.CreateItem("This",
        //                VsaItemType.AppGlobal,
        //                VsaItemFlag.None);
        //            scommand.TypeString = "Ecyware.GreenBlue.Engine.Scripting.ScriptingCommand";
        //
        //            // Add the global "MyScriptingApplication" item
        //            IVsaGlobalItem  sapplication = (IVsaGlobalItem)items.CreateItem("MyScriptingApplication",
        //                VsaItemType.AppGlobal,
        //                VsaItemFlag.None);
        //            sapplication.TypeString = "Ecyware.GreenBlue.Engine.Scripting.ScriptingApplication";
        //            
        ////			_engine.SetOption("print", true);
        //
        ////			// Set the JS output stream once for this appdomain
        ////			if( _jsStream == null )
        ////			{
        ////				StreamWriter    writer = new StreamWriter(@"c:\jsout.txt");
        ////				writer.AutoFlush = true;
        ////				_jsStream = writer;
        ////				Microsoft.JScript.ScriptStream.Out = _jsStream;
        ////			}
        //
        //            try
        //            {
        //                // Run the script
        //                if ( _engine.Compile() )
        //                {
        //                    _engine.Run();
        //                    ExecuteSessionUntilEnd(application, endIndex);
        //                }
        //            }
        //            catch ( Exception ex )
        //            {
        //                System.Windows.Forms.MessageBox.Show(ex.ToString());
        //            }
        //        }
        //
        //
        /// <summary>
        /// Executes a session that executes until the end index.
        /// </summary>
        /// <param name="application"> The scripting application.</param>
        /// <param name="endIndex"> The index where the last request executes.</param>
        public void ExecuteSessionUntilEnd(ScriptingApplication application, int endIndex)
        {
            ScriptingApplication temp = application.Clone();
            temp.ClearWebRequests();

            // if endIndex is 0, we want to include it.
            for ( int i=0;i<=endIndex;i++ )
            {
                // add to new scripting data.
                temp.AddWebRequest(application.WebRequests[i]);
            }

            // Replace Scripting Data with current.
            _sessionScripting = temp;

            // Start from zero.
            IsRunning = true;
            ExecuteRequest(temp.WebRequests[0],0);
        }