private WebSession GetWebSession(TestCasConnectivity.TestCasConnectivityRunInstance instance) { WebSession webSession = this.CreateWebSession(instance); if (instance.UrlType == VirtualDirectoryUriScope.Internal) { webSession.TrustAnySSLCertificate = true; base.WriteVerbose(Strings.CasHealthOwaInternalTrustCertificate); } else if (instance.trustAllCertificates) { webSession.TrustAnySSLCertificate = true; base.WriteVerbose(Strings.CasHealthOwaTrustAnyCertificate); } webSession.SendingRequest += delegate(object sender, HttpWebRequestEventArgs e) { LocalizedString localizedString = Strings.CasHealthWebAppSendingRequest(e.Request.RequestUri); instance.Outcomes.Enqueue(localizedString); }; webSession.ResponseReceived += delegate(object sender, HttpWebResponseEventArgs e) { if (e.Response != null) { string responseHeader = e.Response.GetResponseHeader("X-DiagInfo"); LocalizedString localizedString = Strings.CasHealthWebAppResponseReceived(e.Response.ResponseUri, e.Response.StatusCode, responseHeader ?? string.Empty, TestWebApplicationConnectivity.GetResponseAdditionalInformation(e.Response)); instance.Outcomes.Enqueue(localizedString); } }; webSession.RequestException += delegate(object sender, WebExceptionEventArgs e) { if (e.Response != null) { string responseHeader = e.Response.GetResponseHeader("X-DiagInfo"); LocalizedString localizedString = Strings.CasHealthWebAppRequestException(e.Request.RequestUri, e.Exception.Status, responseHeader ?? string.Empty, e.Exception.Message); instance.Outcomes.Enqueue(localizedString); } }; webSession.Initialize(); return(webSession); }