public void Init() { InitMockData(); _flightCoreServicesMock = new Mock <IFlightServices>(); _flightCoreServicesMock .Setup(service => service.GetAllFlights(It.IsAny <PaginationArgs>())) .Returns((PaginationArgs args) => { var data = new FlightListDto { Total = _flightsMockData.Items.Count(), Items = _flightsMockData.Items .Skip(args.StartIndex.Value) .Take(args.PageSize.Value) }; return(Task.FromResult(data)); }); _flightCoreServicesMock .Setup(service => service.GetFlight(It.IsAny <GetFlightArgs>())) .Returns(async(GetFlightArgs args) => await Task.FromResult(_flightsMockData.Items.Where(f => f.Id == args.FlightId).FirstOrDefault())); _flightCoreServicesMock .Setup(service => service.CreateFlight(It.IsAny <CreateFlightArgs>())) .Returns(Task.FromResult(new FlightDto())); _flightCoreServicesMock .Setup(service => service.UpdateFlight(It.IsAny <UpdateFlightArgs>())) .Returns(Task.FromResult(new FlightDto())); _flightCoreServicesMock .Setup(service => service.DeleteFlight(It.IsAny <int>())) .Returns(Task.FromResult(true)); _airportCoreServicesMock = new Mock <IAirportServices>(); _airportCoreServicesMock .Setup(service => service.GetAllAirports(It.IsAny <PaginationArgs>())) .Returns(Task.FromResult(_airportsMockData.AsEnumerable())); _aircraftCoreServicesMock = new Mock <IAircraftServices>(); _aircraftCoreServicesMock .Setup(service => service.GetAllAircrafts(It.IsAny <PaginationArgs>())) .Returns(Task.FromResult(_aircraftsMockData.AsEnumerable())); }
private void InitMockData() { _flightsMockData = new FlightListDto(); var random = new Random(); var flightItems = new List <FlightDto>(); for (int i = 1; i < 10; i++) { flightItems.Add(new FlightDto { Id = i, FlightNumber = "FakeFlight" + i, AircraftId = i, DepartureAirportId = i, DestinationAirportId = i + 1, FlightDate = DateTime.Now, FlightTime = DateTime.Now }); } _flightsMockData.Items = flightItems; _flightsMockData.Total = flightItems.Count; _airportsMockData = new List <AirportDto>(); for (int i = 1; i < 20; i++) { _airportsMockData.Add(new AirportDto { Id = i, Value = "FakeAirport_" + i }); } _aircraftsMockData = new List <AircraftDto>(); for (int i = 1; i < 20; i++) { _aircraftsMockData.Add(new AircraftDto { Id = i, Value = "FakeAircraft_" + i }); } }