Ejemplo n.º 1
0
        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();
            }
        }
Ejemplo n.º 2
0
        public void WebSourceDisposeClientExpectedDisposesAndNullsClient()
        {
            var source = new WebSource {
                Client = new WebClient()
            };

            Assert.IsNotNull(source.Client);
            source.DisposeClient();
            Assert.IsNull(source.Client);
        }
Ejemplo n.º 3
0
        public void WebSource_Dispose_Client_Expected_Disposes_And_Nulls_Client()
        {
            var source = new WebSource {
                Client = new WebClientWrapper()
            };

            Assert.IsNotNull(source.Client);
            source.DisposeClient();
            Assert.IsNull(source.Client);
        }