public void MW_Should_5_Recent_Posts_With_Title_Body_Set() { var mw = GetMeta(); var posts = new List<Hana.Model.Post>(); for(int i=0;i<10;i++){ var p = new Hana.Model.Post(); p.PostID = i; p.Title = "Title " + i; p.Body = "Body " + i; posts.Add(p); } Hana.Model.Post.Setup(posts); var result = mw.GetRecentPosts("1", "", "", 5); var noTitle = result.Any(x => String.IsNullOrEmpty(x.title)); var noBody = result.Any(x => String.IsNullOrEmpty(x.description)); Assert.False(noTitle); Assert.False(noBody); }
public void MW_Should_Retrieve_Post() { var mw = GetMeta(); var post = new Hana.Model.Post(); post.Body = "La La La"; post.PostID = 1; Hana.Model.Post.Setup(post); var result = mw.GetPost("1", "", "" ); Assert.Equal("La La La", result.description); }
public void MW_Should_Update_Post() { var mw = GetMeta(); var post = new Hana.Model.Post(); post.Body = "La La La"; post.PostID = 1; Hana.Model.Post.Setup(post); Post p=new Post(); p.description = "Jeepers Creepers"; mw.UpdatePost("1", "", "", p, true); post = Hana.Model.Post.SingleOrDefault(x => x.PostID == 1); Assert.Equal("Jeepers Creepers",post.Body); }
public string AddPost(string blogid, string username, string password, Post post, bool publish) { if (ValidateUser(username, password)) { var newPost = new Hana.Model.Post(); newPost.Author = Hana.Model.Blog.Owner; newPost.CreatedOn = DateTime.Now; newPost.ModifiedOn = DateTime.Now; newPost.Title = post.title; newPost.Body = post.description; if (!string.IsNullOrEmpty(post.mt_text_more)) newPost.Body += post.mt_text_more; newPost.Slug = newPost.Title.CreateSlug(); if (!string.IsNullOrEmpty(post.wp_slug)) newPost.Slug = post.wp_slug; var tags = new string[0]; if (!String.IsNullOrEmpty(post.mt_keywords)){ tags = post.mt_keywords.Split(new char[]{','}, StringSplitOptions.RemoveEmptyEntries); newPost.Tags = string.Join(",", tags); } if (publish && post.dateCreated > DateTime.MinValue) { newPost.PublishedOn = post.dateCreated; } else if (publish) { newPost.PublishedOn = DateTime.Now; } else { newPost.PublishedOn = DateTime.Now.AddDays(365); } newPost.Excerpt = Hana.Model.Post.CreateSummary(newPost); newPost.Add(); //save the cats if (post.categories.Length>0) { newPost.CategorySlug = post.categories[0].CreateSlug(); foreach (var c in post.categories) { AssignCategory(newPost.PostID, c); } } if(!String.IsNullOrEmpty(post.mt_keywords)){ foreach (var t in tags) { AssignTag(newPost.PostID,t); } } return Hana.Model.Blog.BlogURL+newPost.Slug; } throw new XmlRpcFaultException(0, "User is not valid!"); }