示例#1
0
        public List <BlogPost> GetPostByID(int id)
        {
            var post = _repo.GetBlogPostByID(id);

            post.CategoryName = _repo.GetCategoryByPostID(post.PostID);
            post.BlogTags     = new List <Tag>();
            post.UserComments = new List <UserComment>();
            var comments = _repo.GetUserCommentsByPostID(post.PostID);

            var tagList = _repo.GetTagsByPostID(post.PostID);

            if (tagList != null)
            {
                foreach (var tag in tagList)
                {
                    post.BlogTags.Add(tag);
                }
            }

            if (comments != null)
            {
                foreach (var comment in comments)
                {
                    post.UserComments.Add(comment);
                }
            }
            var postListCarrier = new List <BlogPost>();

            postListCarrier.Add(post);
            return(postListCarrier);
        }
示例#2
0
        public void GetBlogPostByID_ShouldReturnPostTitle(int postID, string expected)
        {
            var result = repo.GetBlogPostByID(postID).PostTitle;

            Assert.AreEqual(result, expected);
        }