public void Should_PutBookingItem() { BookingItem testBookingItem = new BookingItem { Id = 1 }; Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>(); mock.Setup(f => f.BookingItems.Update(testBookingItem)).Returns(true); BookingItemsController controller = new BookingItemsController(mock.Object); var bookingItems = controller.PutBookingItem(1, testBookingItem); Assert.IsType <NoContentResult>(bookingItems); }
public void ShouldNot_PutBookingItem_ModelStateError() { BookingItem testBookingItem = new BookingItem { Id = 1 }; Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>(); mock.Setup(f => f.BookingItems.Update(testBookingItem)).Returns(true); BookingItemsController controller = new BookingItemsController(mock.Object); controller.ModelState.AddModelError("TestError", "Error"); var bookingItems = controller.PutBookingItem(1, testBookingItem); Assert.IsType <BadRequestObjectResult>(bookingItems); }