Subtext.Framework.XmlRpc.MetaWeblog.newPost C# (CSharp) Method

newPost() public method

Creates a new post. The publish boolean is used to determine whether the item should be published or not.
public newPost ( string blogid, string username, string password, Subtext.Framework.XmlRpc.Post post, bool publish ) : string
blogid string The blogid.
username string The username.
password string The password.
post Subtext.Framework.XmlRpc.Post The post.
publish bool if set to true [publish].
return string
        public string newPost(string blogid, string username, string password, Post post, bool publish)
        {
            return PostContent(username, password, ref post, publish, PostType.BlogPost);
        }

Usage Example

Example #1
0
        public void NewPost_WithNullCategories_DoesNotTHrowException()
        {
            //arrange
            var blog = new Blog { Id = 42, UserName = "******", Password = "******", AllowServiceAccess = true, Host = "localhost" };

            var subtextContext = new Mock<ISubtextContext>();
            subtextContext.Setup(c => c.Blog).Returns(blog);
            Entry publishedEntry = null;
            var entryPublisher = new Mock<IEntryPublisher>();
            entryPublisher.Setup(publisher => publisher.Publish(It.IsAny<Entry>())).Returns(42).Callback<Entry>(
                entry => publishedEntry = entry);

            var api = new MetaWeblog(subtextContext.Object, entryPublisher.Object);
            var post = new Post
            {
                categories = null,
                description = "A unit test",
                title = "A unit testing title",
                dateCreated = DateTime.UtcNow
            };

            // act
            string result = api.newPost(blog.Id.ToString(CultureInfo.InvariantCulture), "username", "password", post,
                                        true);

            // assert
            int entryId = int.Parse(result);
            Assert.AreEqual(42, entryId);
            Assert.AreEqual(0, publishedEntry.Categories.Count, "Should not have added categories.");
        }
All Usage Examples Of Subtext.Framework.XmlRpc.MetaWeblog::newPost