Blog.Logic.Core.Tests.PostsLogicTest.ShouldGetPostsByUser C# (CSharp) Method

ShouldGetPostsByUser() private method

private ShouldGetPostsByUser ( ) : void
return void
        public void ShouldGetPostsByUser()
        {
            var post = _posts.FirstOrDefault(a => a.UserId == 1);
            _postRepository = new Mock<IPostRepository>();
            _postRepository.Setup(a => a.GetByUser(It.IsAny<int>(), It.IsAny<int>()))
                .Returns(new List<Post> { post });

            var postContents = _postContents.Where(a => a.PostId == 1).ToList();
            _postContentRepository = new Mock<IPostContentRepository>();
            _postContentRepository.Setup(a => a.Find(It.IsAny<Expression<Func<PostContent, bool>>>(), true))
                .Returns(postContents);

            _mediaRepository = new Mock<IMediaRepository>();
            _mediaRepository.Setup(a => a.Find(It.IsAny<Expression<Func<Media, bool>>>(), false))
                .Returns(new List<Media> {new Media {MediaId = 1 }});

            _postsLogic = new PostsLogic(_postRepository.Object, _postContentRepository.Object,
                _mediaRepository.Object);

            var result = _postsLogic.GetPostsByUser(1);

            Assert.AreEqual(1, result.Count);
            Assert.AreEqual(1, result[0].User.Id);
        }
PostsLogicTest