コード例 #1
0
        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);
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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);
        }