public async Task DeleteBookingSectorByIdAsync_InputIsBookingSectorData_ReturnsDeletedBookingSectorDTO(int id) { //Arrange bookingSectorRepositoryMock.Setup(b => b.DeleteEntityByIdAsync(It.IsAny <int>())) .ReturnsAsync((int id) => { var bookingSectorToDelete = bookingsSectorContext.Find(b => b.Id == id); if (bookingsSectorContext.Remove(bookingSectorToDelete)) { return(bookingSectorToDelete); } else { return(null); } }); int bookingSectorPreviousCount = bookingsSectorContext.Count; //Act var result = await bookingSectorService.DeleteBookingByIdAsync(id); //Assert Assert.IsNotNull(result); Assert.IsInstanceOf <BookingSectorDTO>(result); Assert.AreEqual(id, result.Id); Assert.AreEqual(bookingSectorPreviousCount - 1, bookingsSectorContext.Count); }
public async Task <IActionResult> Delete([FromRoute] int id) { var booking = await bookingSectorService.DeleteBookingByIdAsync(id); if (booking != null) { return(Ok(booking)); } else { return(NotFound()); } }