public void Delete_ThrowsExceptionIfHobbitDoesNotExist() { Hobbit testHobbit = HobbitHelper.CreateHobbit(FIRST_HOBBIT_NAME); Mock <IDataManager <Hobbit> > mockDataManager = new Mock <IDataManager <Hobbit> >(MockBehavior.Loose); mockDataManager.Setup(dm => dm.TryGet(ID, out testHobbit)).Returns(false); HobbitController controller = new HobbitController(mockDataManager.Object); Assert.Throws <HttpResponseException>(() => controller.Delete(ID)); }
public void Delete_DeletesSpecifiedHobbit() { long testId = ID; Hobbit testHobbit = HobbitHelper.CreateHobbit(FIRST_HOBBIT_NAME); Mock <IDataManager <Hobbit> > mockDataManager = new Mock <IDataManager <Hobbit> >(MockBehavior.Loose); mockDataManager.Setup(dm => dm.TryGet(testId, out testHobbit)).Returns(true); mockDataManager.Setup(dm => dm.Delete(testId)).Returns(true); HobbitController controller = new HobbitController(mockDataManager.Object); controller.Delete(ID); mockDataManager.Verify(dm => dm.Delete(testId), Times.Once()); }