public void Setup() { var repository = new BusStopRepository(Context); var repositoryEmpty = new BusStopRepository(ContextEmpty); var service = new BusStopService(repository, Mapper); var serviceEmpty = new BusStopService(repositoryEmpty, Mapper); _busStopsController = new BusStopsController(service); _busStopsControllerEmpty = new BusStopsController(serviceEmpty); }
public UnitOfWork(ApplicationDbContext db) { _db = db; Wehicle = new WehicleRepository(_db); BusStop = new BusStopRepository(_db); LineName = new LineNameRepository(_db); BusStopList = new BusStopListRepository(_db); Holidays = new HolidaysRepository(_db); Messages = new MessagesRepository(_db); OperatingDays = new OperatingDaysRepository(_db); TicketPrice = new TicketPriceRepository(_db); ArrivalsDepartures = new ArrivalDeparturesRepository(_db); Timetable = new TimetableRepository(_db); BusRoute = new BusRouteRepository(_db); Tickets = new TicketsRepository(_db); Payment = new PaymentRepository(_db); ApplicationUser = new ApplicationUserRepository(_db); ApplicationRole = new ApplicationRoleRepository(_db); BankAccount = new BankAccountRepository(_db); }
public BusController(BusRepository busRepository, BusRouteRepository busRouteRepository, CitizenUserRepository citizenUserRepository, CertificateRepository certificateRepository, BusOrderRepository busOrderRepository, BusWorkerRepository busWorkerRepository, BusStopRepository busStopRepository, IMapper mapper, IWebHostEnvironment hostEnvironment) { this.busRepository = busRepository; this.busRouteRepository = busRouteRepository; this.citizenUserRepository = citizenUserRepository; this.certificateRepository = certificateRepository; this.busOrderRepository = busOrderRepository; this.busWorkerRepository = busWorkerRepository; this.busStopRepository = busStopRepository; this.mapper = mapper; this.hostEnvironment = hostEnvironment; }
public async Task SetUp() { var options = new DbContextOptionsBuilder <DatabaseContext>() .UseInMemoryDatabase(databaseName: "TestDb") .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; context = new DatabaseContext(options); busStopRepository = new BusStopRepository(context); routeRepository = new RouteRepository(context); carrierRepository = new CarrierRepository(context); var routeForTest1 = new Route { Id = 1, Name = "RouteName1", Carrier = new Carrier { Id = 1, Name = "CarrierName1" } }; var routeForTest2 = new Route { Id = 2, Name = "RouteName2", Carrier = new Carrier { Id = 1, Name = "CarrierName1" } }; await busStopRepository.AddBusStopsRangeAsync(new List <BusStop> { new BusStop //FirstRoute { Id = 1, Latitude = 5.0, Longitude = 10.0, Address = "TestAddress1", Label = "TestLabel1", Route = routeForTest1, Hour = new TimeSpan(12, 0, 0), }, new BusStop { Id = 2, Latitude = 15.0, Longitude = 20.0, Address = "TestAddress2", Label = "TestLabel2", Route = routeForTest1, Hour = new TimeSpan(12, 30, 0), }, new BusStop { Id = 3, Latitude = 25.0, Longitude = 30.0, Address = "TestAddress3", Label = "TestLabel3", Route = routeForTest1, Hour = new TimeSpan(13, 00, 0), }, new BusStop //SecondRoute { Id = 4, Latitude = 35.0, Longitude = 40.0, Address = "TestAddress4", Label = "TestLabel4", Route = routeForTest2, Hour = new TimeSpan(16, 0, 0), }, new BusStop { Id = 5, Latitude = 45.0, Longitude = 50.0, Address = "TestAddress5", Label = "TestLabel5", Route = routeForTest2, Hour = new TimeSpan(17, 0, 0), }, new BusStop { Id = 6, Latitude = 55.0, Longitude = 60.0, Address = "TestAddress6", Label = "TestLabel6", Route = routeForTest2, Hour = new TimeSpan(18, 0, 0), } }); await carrierRepository.AddCarrierAsync(new Carrier { Id = 2, Name = "CarrierName2" }); }