Пример #1
0
        public void DestroyCommentCannotDestroyActiveComment()
        {
            // arrange
            var comment = new FeedbackItem(FeedbackType.Comment) { Approved = true };
            var context = new Mock<ISubtextContext>();
            context.Setup(c => c.Repository.GetFeedback(123)).Returns(comment);
            var service = new CommentService(context.Object, null);

            // act, assert
            UnitTestHelper.AssertThrows<InvalidOperationException>(() => service.Destroy(123));
        }
Пример #2
0
        public void Destroy_DestroysTheFeedback()
        {
            // arrange
            var context = new Mock<ISubtextContext>();
            var feedback = new FeedbackItem(FeedbackType.Comment) { Approved = true, Deleted = false };
            context.Setup(c => c.Repository.GetFeedback(112)).Returns(feedback);
            context.Setup(c => c.Repository.DestroyFeedback(123));
            var service = new CommentService(context.Object, null);

            // act
            service.Destroy(123);

            // assert
            context.Verify(c => c.Repository.DestroyFeedback(123));
        }