/// <summary>
        /// Apply the test requests for a session request.
        /// </summary>
        /// <param name="sessionRequest"> The session request.</param>
        /// <param name="result"> The response buffer result from the safe session.</param>
        private void ApplyRequestTests(SessionRequest sessionRequest, ResponseBuffer result)
        {
            UnitTestItem unitTestItem = sessionRequest.WebUnitTest;
            unitTestItem.Form = sessionRequest.Form;

            CookieCollection cookies = null;

            //int availableTests = this.AvailableTests();
            //bool lastItem = false;
            string requestUrl = sessionRequest.Url.ToString();

            #region Run each test in SessionRequest WebUnitTestItem

            // run each test in Form
            foreach (DictionaryEntry de in unitTestItem.Tests)
            {
                Test test = (Test)de.Value;
                ArrayList values = new ArrayList();

                // get cookies
                cookies = cookieManager.GetCookies(sessionRequest.Url);

                // set current test index
                unitTestItem.SelectedTestIndex = unitTestItem.Tests.IndexOfValue(test);

                // create SessionCommandProcessEventArgs
                SessionCommandProcessEventArgs args = new SessionCommandProcessEventArgs("Applying test '" + test.Name + "' to " + sessionRequest.Url.ToString());
                args.ProcessType = SessionProcessType.TestRequest;

                #region Apply Test
                // --------------------------------------------------------------------------------
                // Process data
                // Html Form Tag
                if ( test.UnitTestDataType == UnitTestDataContainer.HtmlFormTag )
                {
                    // is a form tag
                    // apply test to form
                    HtmlFormTag filledForm = ApplyTestToForm(test, sessionRequest.Form.CloneTag());
                    values = parser.ConvertToArrayList(filledForm, result.HttpBody, updateElementNames);
                }
                // Post Data Hashtable
                if ( test.UnitTestDataType == UnitTestDataContainer.PostDataHashtable )
                {
                    string postdata = ((PostSessionRequest)sessionRequest).PostData;

                    // convert post data to hashtable
                    FormConverter converter = new FormConverter();
                    Hashtable postDataHash = converter.ConvertPostDataString(postdata);

                    // Applies test to post data hashtable
                    Hashtable filledPostData = ApplyTestToPostData(test, (Hashtable)postDataHash.Clone());
                    values = converter.ConvertPostDataArrayList(filledPostData);
                }
                // Cookies
                if ( test.UnitTestDataType == UnitTestDataContainer.Cookies )
                {
                    cookies = ApplyTestToCookies(test, cookies);
                }
                // Url
                if( test.UnitTestDataType == UnitTestDataContainer.NoPostData )
                {
                    // a url test
                    requestUrl = ApplyTestToUrl(test, WebServerUriType.Normal,sessionRequest.Url).ToString();
                }
                // -----------------------------------------------------------------------------------
                #endregion

                if ( (test.UnitTestDataType == UnitTestDataContainer.HtmlFormTag ) || ( test.UnitTestDataType == UnitTestDataContainer.PostDataHashtable ) )
                {
                    // Set post data for report
                    test.Arguments.PostData = ConvertToPostDataString(values);
                    args.Detail = "Posted Data:" + test.Arguments.PostData;
                }
                if ( test.UnitTestDataType == UnitTestDataContainer.NoPostData )
                {
                    args.Detail = "Url query:" + requestUrl;
                }
                if ( test.UnitTestDataType == UnitTestDataContainer.Cookies )
                {
                    StringBuilder cookieQuery = new StringBuilder();

                    foreach ( Cookie cky in cookies )
                    {
                        cookieQuery.Append("Name:" + cky.Name);
                        cookieQuery.Append(", ");
                        cookieQuery.Append("Value:" + cky.Value);
                        cookieQuery.Append(";");
                    }

                    args.Detail = "Cookie:" + cookieQuery.ToString();
                }

                //				// set last item flag
                //				if ( availableTests == 1)
                //				{
                //					lastItem = true;
                //				}

                // display the current processing
                this.DisplaySessionProcessEvent(this,args);

                // clone test item and set last item value
                HttpState httpRequestState = new HttpState();
                httpRequestState.TestItem = unitTestItem.Clone();
                //httpRequestState.IsLastItem = lastItem;

                // http settings
                HttpProperties httpSettings = null;
                if ( sessionRequest.RequestHttpSettings == null )
                {
                    httpSettings = unitTestGetRequest.ClientSettings;
                }
                else
                {
                    httpSettings = sessionRequest.RequestHttpSettings;
                }

                if ( sessionRequest.RequestType == HttpRequestType.GET )
                {
                    // get request
                    this.StartGetRequest(unitTestGetRequest,
                        requestUrl,
                        null,
                        cookies,
                        httpSettings,
                        httpRequestState);
                }
                else
                {
                    // post request
                    this.StartPostRequest(unitTestPostRequest,
                        requestUrl,
                        values,
                        cookies,
                        httpSettings,
                        httpRequestState);
                }

                //availableTests--;
            }
            #endregion
        }