Exemplo n.º 1
0
        public void should_be_able_to_login_and_download_xml()
        {
            Scenario.StartNew(this, scenario =>
            {
                scenario.Given(xmlDownloader_is_created_with_valid_credentials);
                scenario.When("getting xml document with valid credentials");
                scenario.Then("the server should return a default reply", ()=>
                {
                    string result = XmlDownloader.GetXmlDocumentString(VALID_URL);
                    result.ShouldNotBeNull();
                    XmlDocument xmlDocument = new XmlDocument();
                    xmlDocument.LoadXml(result);

                    xmlDocument.ShouldNotBeNull();
                });
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// HTTP POST 방식으로 응답을 받아 <see cref="XmlDocument"/> 의 인스턴스로 빌드하여 반환한다.
        /// </summary>
        /// <param name="uri">응답받을 서버 주소</param>
        /// <param name="document">응답 요청시의 Form Parameter 정보</param>
        /// <param name="isAsync">비동기 여부</param>
        /// <param name="timeoutMilliseconds">통신 Timeout</param>
        /// <param name="userId">계정 Id</param>
        /// <param name="password">계정 비밀번호</param>
        /// <returns>응답정보를 담은 <see cref="XmlDocument"/></returns>
        public static XmlDocument PostXml(string uri,
                                          XmlDocument document,
                                          bool isAsync = false,
                                          int timeoutMilliseconds = System.Threading.Timeout.Infinite,
                                          string userId = null,
                                          string password = null) {
            uri.ShouldNotBeWhiteSpace("uri");
            document.ShouldNotBeNull("document");
            Guard.Assert(document.IsValidDocument(), "document is not valid xml document.");

            if(IsDebugEnabled) {
                log.Debug("PostXml... uri=[{0}], isAsync=[{1}], timeout=[{2}], userId=[{3}], password=[{4}], document=[{5}]",
                          uri, isAsync, timeoutMilliseconds, userId, password, document);

                if(document != null)
                    log.Debug("PostXml FormData=[{0}]", document.InnerXml);
            }

            var xmlHttp = new XmlHttpClient(uri, isAsync, timeoutMilliseconds, userId, password);
            return xmlHttp.PostXml(document);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Post 방식의 XmlHttp 통신. XmlDocument를 받는다.
        /// </summary>
        /// <param name="document"></param>
        /// <returns></returns>
        public XmlDocument PostXml(XmlDocument document) {
            document.ShouldNotBeNull("requestDoc");
            Guard.Assert(document.IsValidDocument(), @"document is not valid xml document.");

            using(Stream stream = PostStream(document)) {
                return XmlTool.CreateXmlDocument(stream);
            }
        }
Exemplo n.º 4
0
 public void should_remove_html_tags()
 {
     Scenario.StartNew(this, scenario =>
     {
         scenario.Given(xmlDownloader_is_created_with_valid_credentials);
         scenario.When("getting xml that contains html tags from valid url");
         scenario.Then("XmlDownloader should remove the html tags", ()=>
         {
             string result = XmlDownloader.GetXmlDocumentString(VALID_URL_WITH_HTML_TAGS);
             XmlDocument xmlDocument = new XmlDocument();
             xmlDocument.LoadXml(result);
             xmlDocument.ShouldNotBeNull();
         });
     });
 }
Exemplo n.º 5
0
        /// <summary>
        /// 생성자 - <paramref name="document"/>을 읽어서 새로운 <see cref="XmlDocument"/> 인스턴스를 생성한다.
        /// </summary>
        /// <param name="document">원본 XmlDocument</param>
        public XmlDoc(XmlDocument document) {
            document.ShouldNotBeNull("document");
            Guard.Assert(document.IsValidDocument(), "Invalid content of xml document.");

            LoadXml(document.OuterXml);
        }