public async Task FlightControllerTests_Delete_ShouldCallFlightService_Successfuly() { // Arrange var flightId = 1; var flightController = new FlightsController(_flightCoreServicesMock.Object, _airportCoreServicesMock.Object, _aircraftCoreServicesMock.Object); // Act var result = await flightController.ConfirmDeleteFlight(flightId); // Assert _flightCoreServicesMock.Verify(service => service.DeleteFlight(It.IsAny <int>()), Times.Once); }
public void FlightControllerTests_Delete_ShouldThrowFlightNoFoundExceptionWhenFlightIdIsNotFound() { // Arrange var flightId = 97973; _flightCoreServicesMock.Setup(service => service.DeleteFlight(It.IsAny <int>())) .Throws(new FlightNotFoundException(404, string.Format(ErrorMessages.FLIGHT_NOT_FOUND, flightId))); var flightController = new FlightsController(_flightCoreServicesMock.Object, _airportCoreServicesMock.Object, _aircraftCoreServicesMock.Object); // Act Check.ThatCode(async() => await flightController.ConfirmDeleteFlight(flightId)) .Throws <FlightNotFoundException>() .WithMessage(string.Format(ErrorMessages.FLIGHT_NOT_FOUND, flightId)); }