public void Delete_Test_NegativeParameter() { var mockRepo = new Mock <DevCmsDb>(); mockRepo.SetupDbSetMock(db => db.ContentTypes, GetContentTypeList()); var controller = new ContentTypeController(mockRepo.Object); var result = controller.Delete(-1); Assert.IsType <NotFoundResult>(result); }
public void Delete_Test() { var mockRepo = new Mock <DevCmsDb>(); mockRepo.SetupDbSetMock(db => db.ContentTypes, GetContentTypeList()); Assert.Equal(1, mockRepo.Object.ContentTypes.Count()); var controller = new ContentTypeController(mockRepo.Object); var result = controller.Delete(1); var viewResult = Assert.IsType <RedirectToActionResult>(result); Assert.Equal("Index", viewResult.ActionName); mockRepo.Verify(db => db.SaveChanges(), Times.Once()); Assert.Equal(0, mockRepo.Object.ContentTypes.Count()); }