public void Post_should_map_properties_to_concrete_LinkPostModel() { Post post = new Post { Link = new Link { Type = LinkType.Html, Description = "desc" } }; PostModel model = mapper.Map<Post, PostModel>(post); Assert.AreEqual("desc", ((LinkPostModel)model).LinkDescription); }
public void Post_should_map_to_concrete_LinkPostModel() { Post post = new Post { Link = new Link { Type = LinkType.Html } }; PostModel model = mapper.Map<Post, PostModel>(post); Assert.IsInstanceOfType(model, typeof(LinkPostModel)); }
public void post_should_map_properties_to_concrete_ImagePostModel() { Post post = new Post { Link = new Link { Type = LinkType.Image, Picture = "pic" } }; PostModel model = mapper.Map<Post, PostModel>(post); Assert.AreEqual("pic", ((ImagePostModel)model).LinkPicture); }
public void Post_should_map_Comments_property_even_if_empty() { Post post = new Post { Id = 2, Link = new Link { Type = LinkType.Image, Picture = "pic" } }; PostModel model = mapper.Map<Post, PostModel>(post); Assert.IsNotNull(model.Comments); }
/// <summary> /// Parses links and smileys in user input, removing undersired links, highlighting /// the others, and turning smileys into their appropriate image tags. /// </summary> /// <param name="message">A message provided by a user.</param> /// <param name="post">The post the user message belongs to, if any.</param> /// <returns>The message formatted how we want to display it.</returns> public IHtmlString BeautifyUserMessage(string message, Post post = null) { if (message == null) { return null; } string encoded = HttpUtility.HtmlEncode(message); // all user input must be html-encoded. Func<Uri, bool> filter = uri => post == null || !linkService.AreEqual(uri, post.Link); string hotLinked = linkService.HotLinkHtml(encoded, filter); string htmlString = smileyService.ReplaceSmileys(hotLinked, true); IHtmlString html = new MvcHtmlString(htmlString.TrimAll(includeLineBreaks: false)); return html; }
internal string DetailsRoute(Post post) { return urlHelper.Action("Details", "Posts", new { id = post.Id, slug = postService.GetTitleSlug(post) }); }
public IEnumerable<Comment> GetComments(Post post) { IEnumerable<Comment> comments = commentRepository.GetByPostId(post.Id); return comments; }
public string GetTitleSlug(Post post) { if (post.Link == null) { return textHelper.Slugify(post.UserMessage, 40); } else { return textHelper.Slugify(post.Link.Title); } }