Ejemplo n.º 1
0
        public void Destroy_WithEntryId_CallsDestroyFeedbackOnRepository()
        {
            // arrange
            var feedback = new FeedbackItem(FeedbackType.Comment) { Id = 123, Author = "Calvin"};
            var service = new Mock<ICommentService>();
            service.Setup(s => s.Get(123)).Returns(feedback);
            service.Setup(s => s.Destroy(123));
            var controller = new CommentController(service.Object);

            // act
            var result = controller.Destroy(123) as JsonResult;

            // assert
            service.Verify(c => c.Destroy(123));
            var data = new RouteValueDictionary(result.Data);
            Assert.AreEqual("Comment by Calvin", data["subject"]);
            Assert.AreEqual("was destroyed (there is no undo)", data["predicate"]);
        }
Ejemplo n.º 2
0
        public void Delete_WithEntryId_CallsDeleteEntryOnRepository()
        {
            // arrange
            var feedback = new FeedbackItem(FeedbackType.Comment) { Id = 123, Author = "Bugs" };
            var service = new Mock<ICommentService>();
            service.Setup(s => s.Get(123)).Returns(feedback);
            service.Setup(s => s.UpdateStatus(feedback, FeedbackStatusFlag.Deleted));
            var controller = new CommentController(service.Object);

            // act
            var result = controller.UpdateStatus(123, FeedbackStatusFlag.Deleted) as JsonResult;

            // assert
            service.Verify(c => c.UpdateStatus(feedback, FeedbackStatusFlag.Deleted));
            var data = new RouteValueDictionary(result.Data);
            Assert.AreEqual("Comment by Bugs", data["subject"]);
            Assert.AreEqual("has been removed", data["predicate"]);
        }