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

ShouldThrowExceptionWhenGetPostsFailsOnPostContentsLookup() private method

        public void ShouldThrowExceptionWhenGetPostsFailsOnPostContentsLookup()
        {
            var post = _posts.FirstOrDefault(a => a.PostId == 1);
            _postRepository = new Mock<IPostRepository>();
            _postRepository.Setup(a => a.GetRecent(It.IsAny<Expression<Func<Post, bool>>>(), It.IsAny<int>()))
                .Returns(new List<Post> { post });

            _postContentRepository = new Mock<IPostContentRepository>();
            _postContentRepository.Setup(a => a.Find(It.IsAny<Expression<Func<PostContent, bool>>>(), true))
                .Throws(new Exception());

            _mediaRepository = new Mock<IMediaRepository>();

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

            Assert.Throws<BlogException>(() => _postsLogic.GetRecentPosts(5));
        }
PostsLogicTest