Exemple #1
0
        public void UploadPost()
        {
            var  medium = new MediumApiClient(WeblogInfo);
            bool result = medium.GetUser();

            Assert.IsTrue(result, medium.ErrorMessage);

            var post = new MediumPost()
            {
                tags            = new string[] { "Markdown", "Test" },
                title           = "Test Post #" + DataUtils.GenerateUniqueId(),
                content         = "This is a **test post**.",
                contentFormat   = "markdown",
                publishStatus   = "draft",
                notifyFollowers = false,
                canonicalUrl    = "https://weblog.west-wind.com"
            };

            post = medium.PublishPost(post);

            Assert.IsNotNull(post.url, medium.ErrorMessage);
            Console.WriteLine(post.url);
            Console.WriteLine(post.id);
            ShellUtils.GoUrl(post.url);
        }
Exemple #2
0
        public void UploadCompletePost()
        {
            var  medium = new MediumApiClient(WeblogInfo);
            bool result = medium.GetUser();

            Assert.IsTrue(result, medium.ErrorMessage);

            // make sure there is at least one publication available
            var pubs = medium.GetBlogs();

            Assert.IsNotNull(pubs, medium.ErrorMessage);
            Assert.IsTrue(pubs.Count > 0);

            string pubId = pubs.FirstOrDefault().BlogId as string;

            WeblogInfo.BlogId = pubId;

            var post = new Post
            {
                Tags  = new string[] { "Markdown", "Test" },
                Title = "Test Post #" + DataUtils.GenerateUniqueId(),
                Body  = @"<h1>New Post</h1>
<img src=""MarkdownMonster.png"" />
<p>This is a new post and text and image</p>
"
            };


            var mediumPost = medium.PublishCompletePost(post, documentBasePath: FileUtils.GetPhysicalPath(".\\"));

            Assert.IsNotNull(mediumPost.url, medium.ErrorMessage);
            Console.WriteLine(mediumPost.url);
            Console.WriteLine(mediumPost.id);
            ShellUtils.GoUrl(mediumPost.url);
        }
Exemple #3
0
        public void UploadPostToPublication()
        {
            var  medium = new MediumApiClient(WeblogInfo);
            bool result = medium.GetUser();

            Assert.IsTrue(result, medium.ErrorMessage);

            // make sure there is at least one publication available
            var pubs = medium.GetBlogs();

            Assert.IsNotNull(pubs, medium.ErrorMessage);

            string pubId = pubs.FirstOrDefault().BlogId as string;


            var post = new MediumPost()
            {
                tags            = new string[] { "Markdown", "Test" },
                title           = "Test Post #" + DataUtils.GenerateUniqueId(),
                content         = "This is a **test post**.",
                contentFormat   = "markdown",
                publishStatus   = "draft",
                notifyFollowers = false,
                canonicalUrl    = "https://weblog.west-wind.com"
            };

            post = medium.PublishPost(post, pubId);

            Assert.IsNotNull(post.url, medium.ErrorMessage);
            Console.WriteLine(post.url);
            Console.WriteLine(post.id);
            ShellUtils.GoUrl(post.url);
        }
Exemple #4
0
        public void GetUser()
        {
            var  medium = new MediumApiClient(WeblogInfo);
            bool result = medium.GetUser();

            Assert.IsTrue(result, medium.ErrorMessage);

            Assert.IsNotNull(medium.User.id);
            Console.WriteLine(medium.User.id);
        }
Exemple #5
0
        public void UploadImage()
        {
            var  medium = new MediumApiClient(WeblogInfo);
            bool result = medium.GetUser();

            Assert.IsTrue(result, medium.ErrorMessage);

            string url = medium.PublishImage(".\\MarkdownMonster.png");

            Assert.IsNotNull(url, medium.ErrorMessage);
            Console.WriteLine(url);
            ShellUtils.GoUrl(url);
        }
Exemple #6
0
        public void GetBlogs()
        {
            Console.WriteLine("Starting.");

            var  medium = new MediumApiClient(WeblogInfo);
            bool result = medium.GetUser();

            Assert.IsTrue(result, medium.ErrorMessage);

            var pubs = medium.GetBlogs();

            Assert.IsNotNull(pubs, medium.ErrorMessage);
            foreach (var pub in pubs)
            {
                Console.WriteLine(pub.BlogId + " - " + pub.BlogName);
            }
        }