public void DeleteAttr_Test_NotFound() { var mockRepo = new Mock <DevCmsDb>(); mockRepo.SetupDbSetMock(db => db.ContentAttrs, GetAttributeList()); var controller = new ContentTypeController(mockRepo.Object); var result = controller.DeleteAttr(-1); Assert.IsType <NotFoundResult>(result); result = controller.DeleteAttr(11); Assert.IsType <NotFoundResult>(result); }
public void DeleteAttr_Test() { var mockRepo = new Mock <DevCmsDb>(); mockRepo.SetupDbSetMock(db => db.ContentAttrs, GetAttributeList()); var controller = new ContentTypeController(mockRepo.Object); var result = controller.DeleteAttr(1); var viewResult = Assert.IsType <RedirectToActionResult>(result); Assert.Equal("Edit", viewResult.ActionName); mockRepo.Verify(db => db.SaveChanges(), Times.Once); Assert.Equal(0, mockRepo.Object.ContentAttrs.Count()); }