public void Delete_ShouldReturnNotFound() { mockContext = new Mock <IHotelAC>(); mockSet = new Mock <DbSet <TipSobe> >(); mockContext.Setup(m => m.TipSoba).Returns(mockSet.Object); var controller = new TipSobeController(mockContext.Object); controller.Create(new TipSobe { TipSobeID = 1 }); controller.Delete(2); controller.DeleteConfirmed(2); ActionResult result = controller.Delete(2); Assert.IsInstanceOfType(result, typeof(HttpNotFoundResult), "Room type does not exist"); }
public void Delete_ShouldDeleteRoomType() { mockContext = new Mock <IHotelAC>(); mockSet = new Mock <DbSet <TipSobe> >(); mockContext.Setup(m => m.TipSoba).Returns(mockSet.Object); mockSet.Setup(m => m.Remove(It.IsAny <TipSobe>())); var controller = new TipSobeController(mockContext.Object); controller.Create(new TipSobe { TipSobeID = 1 }); controller.Delete(1); controller.DeleteConfirmed(1); mockSet.Verify(m => m.Remove(It.IsAny <TipSobe>()), Times.Once, "Could not remove the room type"); mockContext.Verify(m => m.SaveChanges(), Times.Exactly(2), "Could not save the changes to the database"); }