Exemplo n.º 1
0
        public void GetLatestPost_ForumHasNoPosts_ReturnsNull()
        {
            //Arrange
            _forumService.GetLatestPost(1).Returns(l => null);

            //Act
            PostListingModel actual = _controller.GetLatestPost(1);

            //Assert
            Assert.Null(actual);
        }
Exemplo n.º 2
0
        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());
        }