/// <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 ExceptionHandler.RegisterException(ex); AbortSessionRun(ex.Message); } }
/// <summary> /// Runs the command. /// </summary> public void Run() { this._isRunning = true; postRequest = new PostForm(); getRequest = new GetForm(); postRequest.EndHttp += new ResponseCallbackDelegate(httpResponse_EndHttp); getRequest.EndHttp += new ResponseCallbackDelegate(httpResponse_EndHttp); reports = new ArrayList(); TestCollection tests = GetTests(); UnitTestItem testItem = new UnitTestItem(FormTag, tests); int availableTests = tests.Count; bool lastItem = false; #region Run each test in UnitTestItem // run each test in Form foreach (DictionaryEntry de in tests) { Test test = (Test)de.Value; // apply test to form HtmlFormTag filledForm = ApplyTestToForm(test, FormTag.CloneTag()); // set current test index testItem.SelectedTestIndex = testItem.Tests.IndexOfValue(test); // resolve uri string url = UriResolver.ResolveUrl(this.Url,filledForm.Action); // convert to array list // TODO: Send HTML Source for bypassing fields. Will be needed for ASP.NET testing. ArrayList al = parser.GetArrayList(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)); HttpState httpRequestState = new HttpState(); httpRequestState.TestItem = testItem.Clone(); httpRequestState.IsLastItem = lastItem; if ( filledForm.Method.ToLower(System.Globalization.CultureInfo.InvariantCulture) == "get" ) { getRequest.StartAsyncHttpGet( url, this.ProtocolProperties, al, cookies, httpRequestState, false); } else { postRequest.StartAsyncHttpPost( url, this.ProtocolProperties, al, cookies, httpRequestState); } availableTests--; } #endregion }