public async Task ClubServiceAircrafFlightTest() { ImportDataTest import = new ImportDataTest(); import.InitContext(); try { _context = import._context; cr = new ClubRepository(_context); AircraftLogBookRepository acr = new AircraftLogBookRepository(_context); FlightRepository fr = new FlightRepository(_context); MemberRepository mr = new MemberRepository(_context); AircraftRepository ar = new AircraftRepository(_context); ClubService clubService = new ClubService(cr, mr, fr, ar, acr, null); int aircraftId = 8; ICollection <Flight> flights = await clubService.GetClubAircraftFlight("BAZ", aircraftId); var group = flights.GroupBy(o => o.Pilot); foreach (var g in group) { System.Diagnostics.Debug.WriteLine(g.FirstOrDefault()?.Pilot?.FirstName); foreach (var gi in g) { System.Diagnostics.Debug.WriteLine(gi.ToString()); } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } }
public void Should_Add_Aircraft() { // Given var options = new DbContextOptionsBuilder <CustomContext>() .UseInMemoryDatabase("TestDB") .EnableSensitiveDataLogging() .Options; // When using (var context = new CustomContext(options)) { var repository = new AircraftRepository(context); var uow = new UnitOfWork(context); repository.Add(_aircraft); uow.Save(); } // Then using (var context = new CustomContext(options)) { var repository = new AircraftRepository(context); var result = repository.GetAll().Single(x => x.ModelName == _aircraft.ModelName); Assert.NotNull(result); } }
public ReportGenerator(AircraftRepository aircraftRepository, AircraftModelRepository aircraftModelRepository, CompanyRepository companyRepository, CountryRepository countryRepository) { _aircraftRepository = aircraftRepository; _aircraftModelRepository = aircraftModelRepository; _companyRepository = companyRepository; _countryRepository = countryRepository; }
public void Should_Add_Flight() { // Given var options = new DbContextOptionsBuilder <CustomContext>() .UseInMemoryDatabase("TestDB") .UseLazyLoadingProxies() .EnableSensitiveDataLogging() .Options; var flightId = 100; // When using (var context = new CustomContext(options)) { context.Database.EnsureCreated(); var uow = new UnitOfWork(context); var repository = new FlightsRepository(context); var airportRepository = new AirportsRepository(context); var aircraftRepository = new AircraftRepository(context); airportRepository.Add(_departureAirport); airportRepository.Add(_destinationAirport); aircraftRepository.Add(_aircraft); uow.Save(); var flight = new Flight(_departureAirport, _destinationAirport, _aircraft) { Id = 100 }; repository.Add(flight); uow.Save(); } // Then using (var context = new CustomContext(options)) { var repository = new FlightsRepository(context); var result = repository.GetAll().Single(x => x.Id == flightId); Assert.NotNull(result); Assert.Equal(_departureAirport.Id, result.DepartureAirport.Id); } }
public async Task RepositoryClubAircrafFlightTest() { ImportDataTest import = new ImportDataTest(); import.InitContext(); try { _context = import._context; cr = new ClubRepository(_context); AircraftLogBookRepository acr = new AircraftLogBookRepository(_context); FlightRepository fr = new FlightRepository(_context); MemberRepository mr = new MemberRepository(_context); ClubRepository _clubRepository = new ClubRepository(_context); AircraftRepository ar = new AircraftRepository(_context); ClubService clubService = new ClubService(cr, mr, fr, ar, acr, null); int aircraftId = 8; var clubSpec = new ClubWithSpecification("BAZ", false, true); var club = (await _clubRepository.ListAsync(clubSpec)); FlighWithSpecification flightPagingSpec = new FlighWithSpecification(0, 10, 8, 14); FlighWithSpecification flightSpec = new FlighWithSpecification(8, 14); var flight = await fr.ListAsync(flightPagingSpec); var flightCount = await fr.CountAsync(flightSpec); ICollection <Flight> flights = await clubService.GetClubAircraftFlight("BAZ", aircraftId); var group = flights.GroupBy(o => o.Pilot); foreach (var g in group) { System.Diagnostics.Debug.WriteLine(g.FirstOrDefault()?.Pilot?.FirstName); foreach (var gi in g) { System.Diagnostics.Debug.WriteLine(gi.ToString()); } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } }
public AircraftService(AircraftRepository repository) { _repository = repository; }
public ContextService(ApplicationDbContext context) { _context = context; GearItems = new GearItemRepository(_context); Aircraft = new AircraftRepository(_context); }