// 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 } }