public void WebSourceDisposeClientExpectedDisposesAndNullsClient() { var source = new WebSource { Client = new WebClient() }; Assert.IsNotNull(source.Client); source.DisposeClient(); Assert.IsNull(source.Client); }
ValidationResult CanConnectServer(WebSource source) { try { ErrorResultTO errors; return new ValidationResult { Result = Execute(source, WebRequestMethod.Get, source.DefaultQuery, (string)null, true, out errors) }; } catch(WebException wex) { RaiseError(wex); var errors = new StringBuilder(); Exception ex = wex; while(ex != null) { errors.AppendFormat("{0} ", ex.Message); ex = ex.InnerException; } return new ValidationResult { IsValid = false, ErrorMessage = errors.ToString() }; } finally { source.DisposeClient(); } }