/// <summary> /// Get Async get request. /// </summary> /// <param name="getUrl"> The url.</param> /// <param name="values"> The get values.</param> /// <param name="cookies"> The cookies.</param> /// <param name="state"> The http state.</param> private void StartGetRequest(GetForm httpCommand, string getUrl, ArrayList values, CookieCollection cookies, HttpProperties settings, HttpState state) { try { httpCommand.StartAsyncHttpGet( getUrl, settings, values, cookies, state, false); } catch (Exception ex) { // register and show Utils.ExceptionHandler.RegisterException(ex); AbortSessionRun(ex.Message); } }
// TODO: Still have to check this function, if is working as intended public void Run() { postRequest = new PostForm(); getRequest = new GetForm(); postRequest.EndHttp += new ResponseCallbackDelegate(httpResponse_EndHttp); getRequest.EndHttp += new ResponseCallbackDelegate(httpResponse_EndHttp); reports = new ArrayList(); UnitTestSession session = this.CurrentUnitTestSession; int availableTests = session.AvailableTests(); bool lastItem = false; // get tests count for (int i=0;i<session.UnitTestForms.Count;i++) { UnitTestItem testItem = session.UnitTestForms.GetByIndex(i); HtmlFormTag form = testItem.Form; #region Run each test in UnitTestItem // run each test in Form foreach (DictionaryEntry de in testItem.Tests) { Test test = (Test)de.Value; // apply test to form HtmlFormTag filledForm = ApplyTestToForm(test,form.CloneTag()); // set current test index testItem.SelectedTestIndex = testItem.Tests.IndexOfValue(test); // get reponse uri Uri uri = (Uri)this.CurrentUnitTestSession.SessionData.ResponseHeaderCollection["Response Uri"]; // resolve uri string url = UriResolver.ResolveUrl(uri,filledForm.Action); // process special fields // filledForm = parser.ProcessSpecialFields(filledForm); // convert to array list ArrayList al = parser.ConvertToArrayList(filledForm); // set posted data StringBuilder postDataBuffer = new StringBuilder(); postDataBuffer.Append("?"); for (int k=0;k<al.Count;k++) { postDataBuffer.Append(al[k]); postDataBuffer.Append("&"); } test.Arguments.PostData = postDataBuffer.ToString(); // set last item flag if ( availableTests == 1) { lastItem = true; } CookieManager cookieManager = new CookieManager(); CookieCollection cookies = cookieManager.GetCookies(new Uri(url)); if ( filledForm.Method.ToLower(System.Globalization.CultureInfo.InvariantCulture) == "get" ) { getRequest.StartAsyncHttpGet( url, this.ProtocolProperties, al, cookies, testItem.Clone(), lastItem); } else { postRequest.StartAsyncHttpPost( url, this.ProtocolProperties, al, cookies, testItem.Clone(), lastItem); } availableTests--; } #endregion } }