public void DeleteTest() { //Arrange List <Flight> flights = new List <Flight>(); var flight1 = new Flight() { LocationFrom = "Lviv", LocationTo = "Kyiv" }; var flight2 = new Flight() { LocationFrom = "Lviv", LocationTo = "Odesa" }; flights.Add(flight1); flights.Add(flight2); //Act flightMockRepository.Setup(x => x.GetAll()).Returns(flights); flightMockRepository.Setup(x => x.Delete(flight1.Id.ToString())); mapper.Setup(x => x.Map <Flight>(flight1)).Returns(flight1); flightService.Delete(flight1.Id); //Assert Assert.Null(flightService.Get(flight1.Id)); }
public IActionResult DeleteFlight(int id) { _flightService.Delete(id); return(RedirectToAction("Flights", "Admin")); }