public void PageControllerDelete_Should_404WhenPageNotExist() { var mockRepo = new Mock <IPageRepository>(); var mockLogger = new Mock <ILogger <PageApiController> >(); mockRepo.Setup(r => r.Remove(1)); var repo = mockRepo.Object; var controller = new PageApiController(repo, mockLogger.Object); var res = controller.DeletePage(1).Result; var error = Assert.IsType <NotFoundResult>(res); Assert.IsType <NotFoundResult>(error); }
public void PageControllerDelete_Should_OkWhenAfterDelete() { var mockRepo = new Mock <IPageRepository>(); var mockLogger = new Mock <ILogger <PageApiController> >(); var page = new Page() { PageId = 1, AddedDate = DateTime.Now, Content = "test" }; mockRepo.Setup(r => r.Get(1)).Returns(page); mockRepo.Setup(r => r.Remove(1)); var repo = mockRepo.Object; var controller = new PageApiController(repo, mockLogger.Object); var res = controller.DeletePage(1).Result; var error = Assert.IsType <OkObjectResult>(res); var error2 = Assert.IsType <OkObjectResult>(res); Assert.IsType <OkObjectResult>(error); }