Exemple #1
0
        public void CreateTest()
        {
            //Arrange
            var flight = new Flight()
            {
                LocationFrom = "Lviv", LocationTo = "Kyiv"
            };
            var flightDTO = new FlightDTO()
            {
                LocationFrom = "Lviv", LocationTo = "Kyiv"
            };

            List <Flight> flights = new List <Flight>();

            flightMockRepository.Setup(x => x.GetAll()).Returns(flights);
            flightMockRepository.Setup(x => x.Create(flight)).Callback((Flight f) => { flights.Add(new Flight()); });
            mapper.Setup(x => x.Map <Flight>(flightDTO)).Returns(flight);

            flightService.Create(flightDTO);

            Assert.Single(flightService.GetAll());
        }
 public IActionResult AddFlight(FlightDTO flight)
 {
     _flightService.Create(flight);
     return(RedirectToAction("Flights", "Admin"));
 }