Esempio 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"]);
        }