private void GetMetaDescrition(String html, String expected)
        {
            String actual = WebpageHelper.GetMetaDescrition(html);

            Assert.IsTrue(actual.Length <= 160);
            Assert.AreEqual(expected, actual);
        }
Пример #2
0
        /// <summary>
        /// Get detail of post
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Details(Int32 id)
        {
            using (var db = new DataService())
            {
                // Initialize mode lwith post from database
                Details model = new Details()
                {
                    Post = db.GetPostWithDetails(id)
                };
                // Post not found
                if (model.Post == null)
                {
                    return(HttpNotFound());
                }
                else
                {
                    // Get description
                    model.Description = WebpageHelper.GetMetaDescrition(model.Post.Summary);

                    // Get previous and next posts informations, to display prevous and next buttons
                    DateTime date = model.Post.DateCreatedGmt;

                    model.PreviousPost = db.GetPreviousPost(id, date);
                    model.NextPost     = db.GetNextPost(id, date);

                    // Build comment model to allow user to comment this post
                    UserProfile user = UserService.Get(db);
                    if (user == null)
                    {
                        model.Comment = null;
                        model.CurrentUserSubscibed = false;
                    }
                    else
                    {
                        model.Comment = new Comment();
                        model.CurrentUserSubscibed = db.HasCurrentUserSubscibed(id, user.Id);
                    }
                }

                return(View(model));
            }
        }