public void GetLatestPost_ForumHasNoPosts_ReturnsNull() { //Arrange _forumService.GetLatestPost(1).Returns(l => null); //Act PostListingModel actual = _controller.GetLatestPost(1); //Assert Assert.Null(actual); }
public PostListingModel GetLatestPost(int forumId) { var post = _forumService.GetLatestPost(forumId); if (post != null) { return(new PostListingModel { Author = post.User != null ? post.User.UserName : "", DatePosted = post.Created.ToString(CultureInfo.InvariantCulture), Title = post.Title ?? "" }); } return(new PostListingModel()); }