/// <summary> /// Returns the result from the safe requests. /// </summary> /// <param name="sender"> The sender object.</param> /// <param name="e"> The ResponseEventArgs.</param> private void SafeSessionResult_EndHttp(object sender, ResponseEventArgs e) { // if is not running, then exit ... if ( this.IsRunning ) { // on return, run each test SessionRequest testRequest = e.State.TestSessionRequest; // add cookies to cookie manager cookieManager.AddCookies(e.Response.CookieCollection); Uri responseUri = (Uri)e.Response.ResponseHeaderCollection["Response Uri"]; // // Update Session Headers // if ( ( testRequest.Url.ToString() != responseUri.ToString() ) && ( responseUri != null ) ) // { // // Updates the Test Url with the response uri from the safe session // testRequest.Url = responseUri; // } try { #region Apply Tests and execute safe requests if ( testRequest.WebUnitTest != null ) { if ( testRequest.WebUnitTest.Tests != null ) { #region Apply tests if ( ( testRequest.WebUnitTest.Tests.Count > 0 ) ) { // matchId > currentRestart // apply tests ApplyRequestTests(testRequest, e.Response); } #endregion // add safe test report // HtmlUnitTestReport report = rptBuilder.BuildReport(e); // reports.Add(report); HttpState state = new HttpState(); state.SessionRequestId = e.State.SessionRequestId + 1; // if equal, then we stop to request and enabled the report. if ( state.SessionRequestId == this.SafeSession.SessionRequests.Count ) { // end // show report UnitTestSessionReportEventArgs args = new UnitTestSessionReportEventArgs(); args.Report = reports; this.CreateReportEvent(this, args); } else { // continue state.TestSessionRequest = this.TestSession.SessionRequests[state.SessionRequestId]; ResponseBuffer inputResponse = e.Response; // call safe request backtracking else call next safe request directly if ( this.SafeSession.AllowSafeRequestBacktracking ) { this.ExecuteNextSafeRequestById(state, inputResponse, state.SessionRequestId); } else { this.ExecuteNextSafeRequest(state, inputResponse); } } } } #endregion } catch ( WebException web) { Utils.ExceptionHandler.RegisterException(web); AbortSessionRun(web.Message); } catch (Exception ex) { Utils.ExceptionHandler.RegisterException(ex); AbortSessionRun(ex.Message); } } else { // abort requests this.safeSessionGetRequest.SafeAbortRequest(); this.safeSessionPostRequest.SafeAbortRequest(); } }
/// <summary> /// Aborts the session and updates the pending reports. /// </summary> /// <param name="message"> The message to show.</param> private void AbortSessionRun(string message) { this._isRunning = false; if ( reports.Count > 0 ) { // show report UnitTestSessionReportEventArgs args = new UnitTestSessionReportEventArgs(); args.Report = reports; this.CreateReportEvent(this, args); } SessionAbortEventArgs sargs = new SessionAbortEventArgs(); sargs.ErrorMessage = message; this.SessionAbortedEvent(this, sargs); }
/// <summary> /// Callback to ShowReport method. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void UrlSpider_CreateReportEvent(object sender, UnitTestSessionReportEventArgs e) { object[] param={e.Report}; this.Invoke(new GetReportCallback(UrlSpiderShowReport),param); }
/// <summary> /// Callback to ShowReport method. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EasyTest_CreateReportEvent(object sender, UnitTestSessionReportEventArgs e) { object[] param={e.Report}; this.Invoke(new GetReportCallback(EasyTestReport),param); }
private void httpResponse_EndHttp(object sender,ResponseEventArgs e) { if ( e == null) return; // TODO: Use Invoke this.DisplayProcessEvent(this, e); // add response to report ReportBuilder rptBuilder = new ReportBuilder(); HtmlUnitTestReport report = rptBuilder.BuildReport(e); reports.Add(report); if ( e.IsSessionLastItem ) { // show report UnitTestSessionReportEventArgs args = new UnitTestSessionReportEventArgs(); args.Report = reports; this.CreateReportEvent(this,args); } }
/// <summary> /// Returns the result from the unit test execution. /// </summary> /// <param name="sender"> The sender object.</param> /// <param name="e"> The ResponseEventArgs type.</param> private void httpResponse_EndHttp(object sender,ResponseEventArgs e) { if ( e != null) { this.DisplayProcessEvent(this, e); HttpState state = (HttpState)e.State; // check test result Test test = state.TestItem.Tests.GetByIndex(((HttpState)e.State).TestItem.SelectedTestIndex); UnitTestResult testResult = asdeCommand.CheckTestResult(e.Response, test); // add response to report HtmlUnitTestReport report = rptBuilder.BuildReport(e, testResult); reports.Add(report); if ( state.IsLastItem ) { this._isRunning = false; // show report UnitTestSessionReportEventArgs args = new UnitTestSessionReportEventArgs(); args.Report = reports; this.CreateReportEvent(this,args); } } }