public async Task <IActionResult> Delete(string number) { try { await _flightsService.DeleteAsync(number); return(NoContent()); } catch (NotExistException) { return(NotFound()); } }
public async Task DeleteAsync_ShouldSuccessfullyDelete() { // Arrange var context = ApplicationDbContextInMemoryFactory.InitializeContext(); var seeder = new FlightsServiceTestsSeeder(); await seeder.SeedFlightAsync(context); var flightRepository = new EfDeletableEntityRepository <Flight>(context); var service = new FlightsService(flightRepository); var flightId = flightRepository.All().First().Id; // Act var flightsCount = flightRepository.All().Count(); await service.DeleteAsync(flightId); var actualResult = flightRepository.All().Count(); var expectedResult = flightsCount - 1; // Assert Assert.True(actualResult == expectedResult); }