コード例 #1
0
ファイル: Test.cs プロジェクト: chonghua/OpenLiveWriter-zh-CN
        public sealed override void DoTest(Blog blog, IBlogClient blogClient, ITestResults results)
        {
            BlogPost blogPost = new BlogPost();
            bool?    publish  = null;

            PreparePost(blogPost, ref publish);

            string token = BlogUtil.ShortGuid;

            blogPost.Title = token + ":" + blogPost.Title;

            string      etag;
            XmlDocument remotePost;
            string      postId = blogClient.NewPost(blog.BlogId, blogPost, null, publish ?? true, out etag, out remotePost);

            try
            {
                RetryUntilTimeout(TimeoutDuration, delegate
                {
                    using (HttpWebResponse response = HttpRequestHelper.SendRequest(blog.HomepageUrl))
                    {
                        using (Stream stream = response.GetResponseStream())
                        {
                            string html = Encoding.ASCII.GetString(StreamHelper.AsBytes(stream));

                            if (html.Contains(token))
                            {
                                HandleResult(html, results);
                                return(true);
                            }

                            Thread.Sleep(1000);
                            return(false);
                        }
                    }
                });
            }
            catch (TimeoutException te)
            {
                if (!HandleTimeout(te, results))
                {
                    throw;
                }
            }

            if (postId != null && CleanUpPosts)
            {
                blogClient.DeletePost(blog.BlogId, postId, false);
            }
        }
コード例 #2
0
ファイル: Test.cs プロジェクト: evilpaladique/OpenLiveWriter
        public sealed override void DoTest(Blog blog, IBlogClient blogClient, ITestResults results)
        {
            BlogPost blogPost = new BlogPost();
            bool?    publish  = null;

            PreparePost(blog, blogClient, blogPost, ref publish);

            string token = BlogUtil.ShortGuid;

            blogPost.Title = token + ":" + blogPost.Title;

            string      etag;
            XmlDocument remotePost;
            string      postId  = blogClient.NewPost(blog.BlogId, blogPost, null, publish ?? true, out etag, out remotePost);
            BlogPost    newPost = blogClient.GetPost(blog.BlogId, postId);

            HandleResult(newPost, results);
            if (postId != null && CleanUpPosts)
            {
                blogClient.DeletePost(blog.BlogId, postId, false);
            }
        }
コード例 #3
0
ファイル: Test.cs プロジェクト: gmilazzoitag/OpenLiveWriter
        public sealed override void DoTest(Blog blog, IBlogClient blogClient, ITestResults results)
        {
            BlogPost blogPost = new BlogPost();
            bool? publish = null;
            PreparePost(blogPost, ref publish);

            string token = BlogUtil.ShortGuid;
            blogPost.Title = token + ":" + blogPost.Title;

            string etag;
            XmlDocument remotePost;
            string postId = blogClient.NewPost(blog.BlogId, blogPost, null, publish ?? true, out etag, out remotePost);

            try
            {
                RetryUntilTimeout(TimeoutDuration, delegate
                {
                    using (HttpWebResponse response = HttpRequestHelper.SendRequest(blog.HomepageUrl))
                    {
                        using (Stream stream = response.GetResponseStream())
                        {
                            string html = Encoding.ASCII.GetString(StreamHelper.AsBytes(stream));

                            if (html.Contains(token))
                            {
                                HandleResult(html, results);
                                return true;
                            }

                            Thread.Sleep(1000);
                            return false;
                        }
                    }
                });
            }
            catch (TimeoutException te)
            {
                if (!HandleTimeout(te, results))
                    throw;
            }

            if (postId != null && CleanUpPosts)
                blogClient.DeletePost(blog.BlogId, postId, false);
        }
コード例 #4
0
ファイル: Test.cs プロジェクト: gmilazzoitag/OpenLiveWriter
        public sealed override void DoTest(Blog blog, IBlogClient blogClient, ITestResults results)
        {
            BlogPost blogPost = new BlogPost();
            bool? publish = null;
            PreparePost(blog, blogClient, blogPost, ref publish);

            string token = BlogUtil.ShortGuid;
            blogPost.Title = token + ":" + blogPost.Title;

            string etag;
            XmlDocument remotePost;
            string postId = blogClient.NewPost(blog.BlogId, blogPost, null, publish ?? true, out etag, out remotePost);
            BlogPost newPost = blogClient.GetPost(blog.BlogId, postId);
            HandleResult(newPost, results);
            if (postId != null && CleanUpPosts)
                blogClient.DeletePost(blog.BlogId, postId, false);
        }