private static BlogConnectionInfo GetBlog2() { var con1 = new BlogConnectionInfo( "http://localhost:14228/test2", "http://localhost:14882/test2/metaweblog.axd", "test2", "admin", "admin"); return con1; }
public static void SaveBlogConnectionInfo(MP.BlogConnectionInfo coninfo, string filename) { var doc = new System.Xml.Linq.XDocument(); var p = new System.Xml.Linq.XElement("blogconnectioninfo"); doc.Add(p); p.Add(new System.Xml.Linq.XElement("blogurl", coninfo.BlogUrl)); p.Add(new System.Xml.Linq.XElement("blogid", coninfo.BlogId)); p.Add(new System.Xml.Linq.XElement("metaweblog_url", coninfo.MetaWeblogUrl)); p.Add(new System.Xml.Linq.XElement("username", coninfo.Username)); p.Add(new System.Xml.Linq.XElement("password", coninfo.Password)); doc.Save(filename); }
public async Task GetPosts1() { var con1 = GetBlog1(); var con2 = new BlogConnectionInfo( "http://localhost:14228/test2", "http://localhost:14882/test2/metaweblog.axd", "test2", "admin", "admin"); var client = new Client(con1); var posts = await client.GetRecentPosts(10000); foreach (var p in posts) { await client.DeletePost(p.PostId); } posts = await client.GetRecentPosts(10000); Assert.AreEqual(0,posts.Count); // create and verify a normal post string postid = await client.NewPost("P1", "P1Content", null, false, null); posts = await client.GetRecentPosts(10000); Assert.AreEqual(1,posts.Count); Assert.AreEqual(postid, posts[0].PostId); // Create another post string postid2 = await client.NewPost("P2", "P2Content", null, false, null); posts = await client.GetRecentPosts(10000); Assert.AreEqual(2, posts.Count); Assert.AreEqual(postid2, posts[0].PostId); Assert.AreEqual(postid, posts[1].PostId); Assert.AreEqual(null, posts[0].PostStatus); var firstPost = posts[0]; string newTitle = firstPost.Title + " Updated"; await client.EditPost(firstPost.PostId, newTitle , firstPost.Description, null, true); var firstPostUpdated = await client.GetPost(firstPost.PostId); Assert.AreEqual(newTitle, firstPostUpdated.Title); }
public static MP.BlogConnectionInfo LoadBlogConnectionInfo(string filename) { var doc = System.Xml.Linq.XDocument.Load(filename); var root = doc.Root; string blogurl = root.GetElementString("blogurl"); string blogId = root.GetElementString("blogid"); string metaWeblogUrl = root.GetElementString("metaweblog_url"); string username = root.GetElementString("username"); string password = root.GetElementString("password"); var coninfo = new BlogConnectionInfo(blogurl, metaWeblogUrl, blogId, username, password); return coninfo; }
/// <summary> /// /// </summary> /// <param name="connectionInfo"></param> public Client(BlogConnectionInfo connectionInfo) { this.BlogConnectionInfo = connectionInfo; }