public void ShouldThrowExceptionWhenDeletingCommunityFails()
        {
            var community = new Community { Id = 1, Name = "lorem", Description = "fudge brownies" };

            _communityRepository = new Mock<ICommunityRepository>();
            _communityRepository.Setup(a => a.Delete(It.IsAny<Community>())).Throws(new Exception("Hooha!"));
            _communityRepository.Setup(a => a.Find(It.IsAny<Expression<Func<Community, bool>>>(), false))
                .Returns(new List<Community> { community });

            var logic = new CommunityLogic(_communityRepository.Object);

            Assert.Throws<BlogException>(() => logic.Delete(1));
        }
        public void ShouldReturnFalseWhenNoRecordFoundOnDelete()
        {
            _communityRepository = new Mock<ICommunityRepository>();
            _communityRepository.Setup(a => a.Find(It.IsAny<Expression<Func<Community, bool>>>(), false))
                .Returns(new List<Community>());

            var logic = new CommunityLogic(_communityRepository.Object);
            var result = logic.Delete(1);

            Assert.IsFalse(result);
        }
        public void ShouldThrowExceptionWhenDeletingCommunityFailsOnGettingRecord()
        {
            _communityRepository = new Mock<ICommunityRepository>();
            _communityRepository.Setup(a => a.Delete(It.IsAny<Community>()));
            _communityRepository.Setup(a => a.Find(It.IsAny<Expression<Func<Community, bool>>>(), false))
                .Throws(new Exception("Hooha!"));


            var logic = new CommunityLogic(_communityRepository.Object);

            Assert.Throws<BlogException>(() => logic.Delete(1));
        }
        public void ShouldDeleteCommunity()
        {
            var community = new Community { Id = 1, Name = "lorem", Description = "fudge brownies" };

            _communityRepository = new Mock<ICommunityRepository>();
            _communityRepository.Setup(a => a.Delete(It.IsAny<Community>()));
            _communityRepository.Setup(a => a.Find(It.IsAny<Expression<Func<Community, bool>>>(), false))
                .Returns(new List<Community> { community });

            var logic = new CommunityLogic(_communityRepository.Object);
            var result = logic.Delete(1);

            Assert.IsTrue(result);
        }