public void AddFlight(FlightDetail flightDetail)
        {
            Flight flight = new Flight
            {
                ArrivalTime = flightDetail.ArrivalTime,
                DepartureTime = flightDetail.DepartureTime,
                Id = _flightRepository.Get().Count() + 1
            };

            AirportFlight airportFlight = new AirportFlight()
            {
                ArriveAirportId = _airportRepository.Get().FirstOrDefault(x => x.Name == flightDetail.ArrivalAirport).Id,
                DepartureAirportId = _airportRepository.Get().FirstOrDefault(x => x.Name == flightDetail.DepartureAirport).Id,
                FlightId = _flightRepository.Get().Count()
            };

            _flightRepository.Add(flight);
            _airportFlightRepository.Add(airportFlight);
        }
        public void Given_i_have_added_a_new_flight_i_should_see_the_new_flight_in_list_of_flights()
        {
            //Arrange
            FlightDetail flightDetail = new FlightDetail()
            {
                ArrivalAirport = "Gatwick",
                DepartureAirport = "Luton",
                ArrivalTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 14, 0, 0),
                DepartureTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 17, 0, 0)
            };

            IFlightReservationService facade = new FlightReservationService(_airportRepository, _flightRepository, _airportFlightRepository);

            //Act
            facade.AddFlight(flightDetail);
            var result = facade.GetFlightDetail();

            //Assert
            Assert.AreEqual(5, result.Count());
        }
        public void ShouldSeeTheNewlyAddedFlightInList()
        {
            //Arrange
            _mockFlightRepository.Setup(x => x.Get()).Returns(Given_A_List_Flights());
            _mockAirportFlightRepository.Setup(x => x.Get()).Returns(Given_A_List_Of_Airport_Flights());
            _mockAirportRepository.Setup(x => x.Get()).Returns(Given_A_list_Of_Airports());
            //_mockFlightRepository.Setup(x => x.Add(It.IsAny<Flight>()));
            //_mockAirportFlightRepository.Setup(x => x.Add(It.IsAny<AirportFlight>()));

            FlightDetail flightDetail = new FlightDetail()
            {
                ArrivalAirport = "Gatwick",
                DepartureAirport = "Luton",
                ArrivalTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 14, 0, 0),
                DepartureTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 17, 0, 0)
            };
            //Act
            service.AddFlight(flightDetail);

            //Assert
            _mockFlightRepository.Verify(x => x.Add(It.IsAny<Flight>()));
            _mockAirportFlightRepository.Verify(x => x.Add(It.IsAny<AirportFlight>()));
            //_mockAirportFlightRepository.Verify(x => x.Update(It.IsAny<AirportFlight>()));
        }