public void ShouldReturnFalseWhenDeletePostContentFoundNoRecord() { _postContentRepository = new Mock<IPostContentRepository>(); _postContentRepository.Setup(a => a.Find(It.IsAny<Expression<Func<PostContent, bool>>>(), false)) .Returns(new List<PostContent>()); _postContentsLogic = new PostContentsLogic(_postContentRepository.Object); var result = _postContentsLogic.Delete(1); Assert.IsFalse(result); }
public void ShouldThrowExceptionWhenDeletePostContentFails() { _postContentRepository = new Mock<IPostContentRepository>(); _postContentRepository.Setup(a => a.Delete(It.IsAny<PostContent>())).Throws(new Exception()); _postContentsLogic = new PostContentsLogic(_postContentRepository.Object); Assert.Throws<BlogException>(() => _postContentsLogic.Delete(1)); }
public void ShouldReturnTrueOnDeletePostContent() { var dbResult = new List<PostContent> { new PostContent { PostContentId = 1 } }; _postContentRepository = new Mock<IPostContentRepository>(); _postContentRepository.Setup(a => a.Find(It.IsAny<Expression<Func<PostContent, bool>>>(), false)) .Returns(dbResult); _postContentsLogic = new PostContentsLogic(_postContentRepository.Object); var result = _postContentsLogic.Delete(1); Assert.IsTrue(result); }