public UnitOfWork(IDbConnection connection) { _connection = connection; AccountDao = new AccountDao(connection); BusCoordinateDao = new BusCoordinateDao(connection); BusDao = new BusDao(connection); BusDriverDao = new BusDriverDao(connection); CityDao = new CityDao(connection); CountryDao = new CountryDao(connection); DistanceDao = new DistanceDao(connection); DistrictDao = new DistrictDao(connection); DriverDao = new DriverDao(connection); DriverContactDao = new DriverContactDao(connection); LocationDao = new LocationDao(connection); LookupsDao = new LookupsDao(connection); LookupValuesDao = new LookupValuesDao(connection); RepairSpecialistDao = new RepairSpecialistDao(connection); RoleDao = new RoleDao(connection); RouteDao = new RouteDao(connection); RouteLocationDao = new RouteLocationDao(connection); TripDao = new TripDao(connection); TripBusDao = new TripBusDao(connection); TripBusDriverDao = new TripBusDriverDao(connection); UserDao = new UserDao(connection); VehicleDao = new VehicleDao(connection); ScheduleDao = new ScheduleDao(connection); ScheduleLocationDao = new ScheduleLocationDao(connection); StoredProcedureDao = new StoredProcedureDao(connection); }
protected TestBase() { var config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build(); var section = config.GetSection("ConnectionStrings").GetSection("huraceTest"); var provider = section["ProviderName"]; var connectionString = section["ConnectionString"]; ConnectionFactory = new ConcreteConnectionFactory(DbUtil.GetProviderFactory(provider), connectionString); RaceDao = new RaceDao(ConnectionFactory, StatementFactory); SeasonDao = new SeasonDao(ConnectionFactory, StatementFactory); LocationDao = new LocationDao(ConnectionFactory, StatementFactory); CountryDao = new CountryDao(ConnectionFactory, StatementFactory); DisciplineDao = new DisciplineDao(ConnectionFactory, StatementFactory); SkierDao = new SkierDao(ConnectionFactory, StatementFactory); StartListDao = new StartListDao(ConnectionFactory, StatementFactory); RaceEventDao = new RaceEventDao(ConnectionFactory, StatementFactory); SkierEventDao = new SkierEventDao(ConnectionFactory, StatementFactory); TimeDataDao = new TimeDataDao(ConnectionFactory, StatementFactory); GenderDao = new GenderDao(ConnectionFactory, StatementFactory); SensorDao = new SensorDao(ConnectionFactory, StatementFactory); RaceDataDao = new RaceDataDao(ConnectionFactory, StatementFactory); RaceStateDao = new RaceStateDao(ConnectionFactory, StatementFactory); StartStateDao = new StartStateDao(ConnectionFactory, StatementFactory); EventTypeDao = new EventTypeDao(ConnectionFactory, StatementFactory); _dataGenerator = new DataGenerator.Core.DataGenerator(provider, connectionString); }
public override void Initialize() { var connectionString = ConfigurationReader.GetConnectionString(Environment.Production); var databaseName = GetDatabaseName(connectionString); var task = Task.Run(async() => await ApplicationData.Current.LocalFolder.CreateFileAsync(databaseName, CreationCollisionOption.OpenIfExists)).Result; var databasePath = Path.Combine(ApplicationData.Current.LocalFolder.Path, databaseName); var customConnectionString = connectionString.Replace(databaseName, databasePath, StringComparison.CurrentCulture); var connectionFactory = new ConnectionFactory(Environment.Production, customConnectionString); var locationDao = new LocationDao(connectionFactory); var skierDao = new SkierDao(connectionFactory); var countryDao = new CountryDao(connectionFactory); var raceDao = new RaceDao(connectionFactory); var runDao = new RunDao(connectionFactory); var sensorMeasurementDao = new SensorMeasurementDao(connectionFactory); var daoProvider = new DaoProvider(countryDao, locationDao, raceDao, runDao, sensorMeasurementDao, skierDao); var messengerHub = new MvxMessengerHub(); var simulatorRaceClock = new SimulatorRaceClock(); Mvx.IoCProvider.RegisterSingleton <IMvxMessenger>(messengerHub); Mvx.IoCProvider.RegisterSingleton <IDialogService>(new DialogService(messengerHub)); Mvx.IoCProvider.RegisterSingleton <IRaceService>(new RaceService(daoProvider)); Mvx.IoCProvider.RegisterSingleton <ILocationService>(new LocationService(daoProvider)); Mvx.IoCProvider.RegisterSingleton <ISkierService>(new SkierService(daoProvider)); Mvx.IoCProvider.RegisterSingleton <IRunService>(new RunService(daoProvider, simulatorRaceClock)); Mvx.IoCProvider.RegisterSingleton <SimulatorRaceClock>(simulatorRaceClock); RegisterAppStart <ViewModels.NavigationRootViewModel>(); }
public void AddLocation(LocationDao location) { var latId = (int)((location.Latitude - _latitudeDownBoundary) / _latStep); var longId = (int)((location.Longitude - _longitudeDownBoundary) / _longStep); var timeId = (int)((location.Time - _timeDownBoundary) / _timeStep); var cube = _coronaContext.Cubes.FirstOrDefault(c => c.LatId == latId && longId == c.LongId && timeId == c.TimeId); if (cube == null) { cube = new Cube { LatId = latId, LongId = longId, TimeId = timeId }; _coronaContext.Cubes.Add(cube); } var dbLocation = new Location { AddDate = DateTime.Now, Latitude = location.Latitude, Longitude = location.Longitude, LatId = cube.LatId, LongId = cube.LongId, TimeId = cube.TimeId, Time = location.Time, UserId = location.UserId }; _coronaContext.Locations.Add(dbLocation); _coronaContext.SaveChanges(); }
public async Task InsertTest() { var disciplineId = (await DisciplineDao.FindAllAsync()).First().Id; var locationId = (await LocationDao.FindAllAsync()).First().Id; var seasonId = (await SeasonDao.FindAllAsync()).First().Id; var raceId = await RaceDao.InsertGetIdAsync(new Race { DisciplineId = disciplineId, GenderId = (int)Domain.Enums.Gender.Male, LocationId = locationId, RaceDescription = "Description", SeasonId = seasonId, RaceStateId = (int)Domain.Enums.RaceDataEvent.RaceFinished, RaceDate = new DateTime(2019, 11, 15) }); var raceById = await RaceDao.FindByIdAsync(raceId.Value); Assert.AreEqual(disciplineId, raceById.DisciplineId); Assert.AreEqual((int)Domain.Enums.Gender.Male, raceById.GenderId); Assert.AreEqual(locationId, raceById.LocationId); Assert.AreEqual("Description", raceById.RaceDescription); Assert.AreEqual(seasonId, raceById.SeasonId); Assert.AreEqual((int)Domain.Enums.RaceDataEvent.RaceFinished, raceById.RaceStateId); Assert.AreEqual(new DateTime(2019, 11, 15), raceById.RaceDate); Assert.NotNull(raceById.Location); Assert.NotNull(raceById.Gender); Assert.NotNull(raceById.Season); }
public async Task RemovePossibleDisciplineTest() { var location = (await LocationDao.FindAllAsync()).First(); var disciplineId = (await DisciplineDao.FindAllAsync()).First().Id; await LocationDao.DeletePossibleDisciplineForLocation(location.Id, disciplineId); Assert.AreEqual(1, (await LocationDao.GetPossibleDisciplinesForLocation(location.Id)).Count()); }
public async Task UpdateTest() { var location = (await LocationDao.FindAllAsync()).First(); location.LocationName = "Test123"; await LocationDao.UpdateAsync(location); Assert.AreEqual(location.LocationName, (await LocationDao.FindByIdAsync(location.Id))?.LocationName); }
public async void TestFindById() { ConnectionFactory connectionFactory = new ConnectionFactory(Environment.Testing); ILocationDao locationDao = new LocationDao(connectionFactory); Location location = await InsertLocation(connectionFactory); Location locationFound = await locationDao.FindById(location.Id); Assert.Equal(location.Name, locationFound.Name); }
public async Task InsertTest() { var countryId = (await CountryDao.FindAllAsync()).First().Id; var locationId = await LocationDao.InsertGetIdAsync(new Location { CountryId = countryId, LocationName = "Name" }); Assert.AreEqual("Name", (await LocationDao.FindByIdAsync(locationId.Value))?.LocationName); Assert.NotNull((await LocationDao.FindByIdAsync(locationId.Value))?.Country); }
public async Task AddPossibleDisciplineTest() { var location = (await LocationDao.FindAllAsync()).First(); var disciplineId = await DisciplineDao.InsertGetIdAsync(new Discipline { DisciplineName = "XYZ" }); await LocationDao.InsertPossibleDisciplineForLocation(location.Id, disciplineId.Value); Assert.AreEqual(3, (await LocationDao.GetPossibleDisciplinesForLocation(location.Id)).Count()); }
public async Task DeleteTest() { var id = await LocationDao.InsertGetIdAsync(new Location { CountryId = (await CountryDao.FindAllAsync()).First().Id, LocationName = "AAA" }); await LocationDao.DeleteAsync(id.Value); Assert.IsNull(await LocationDao.FindByIdAsync(id.Value)); }
public Location DaoToEntity(LocationDao dao) { Location entity = new Location { Id = dao.Id, Address = dao.Address, City = dao.City, Country = dao.Country, Language = dao.Language }; return(entity); }
public LocationDao EntityToDao(Location entity) { LocationDao dao = new LocationDao { Id = entity.Id, Address = entity.Address, City = entity.City, Country = entity.Country, Language = entity.Language }; return(dao); }
public async void TestDelete() { ConnectionFactory connectionFactory = new ConnectionFactory(Environment.Testing); ILocationDao locationDao = new LocationDao(connectionFactory); Location location = await InsertLocation(connectionFactory); Assert.NotNull(await locationDao.FindById(location.Id)); await locationDao.Delete(location.Id); Assert.Null(await locationDao.FindById(location.Id)); }
public async void TestUpdate() { ConnectionFactory connectionFactory = new ConnectionFactory(Environment.Testing); ILocationDao locationDao = new LocationDao(connectionFactory); Location location = await InsertLocation(connectionFactory); location.Name = "Hinterstoder"; await locationDao.Update(location); Location locationAfter = await locationDao.FindById(location.Id); Assert.Equal(location.Name, locationAfter.Name); }
public static async Task <Location> InsertLocation(ConnectionFactory connectionFactory, Country country = null) { ILocationDao locationDao = new LocationDao(connectionFactory); country ??= await CountryDaoTests.InsertCountry(connectionFactory); Location location = new Location { Name = "Kitzbühel", Country = country, }; location.Id = await locationDao.Insert(location); return(location); }
public async void TestFindAll() { ConnectionFactory connectionFactory = new ConnectionFactory(Environment.Testing); ILocationDao locationDao = new LocationDao(connectionFactory); foreach (var _ in await locationDao.FindAll()) { Assert.True(false, "FindAll should return an empty collection"); } await InsertLocation(connectionFactory); foreach (var _ in await locationDao.FindAll()) { return; } Assert.True(false, "FindAll should return a non-empty collection"); }
private void AddHuraceServices(IServiceCollection services) { var connectionString = ConfigurationReader.GetConnectionString(Environment.Production); var connectionFactory = new ConnectionFactory(Environment.Production, connectionString); var locationDao = new LocationDao(connectionFactory); var skierDao = new SkierDao(connectionFactory); var countryDao = new CountryDao(connectionFactory); var raceDao = new RaceDao(connectionFactory); var runDao = new RunDao(connectionFactory); var sensorMeasurementDao = new SensorMeasurementDao(connectionFactory); var daoProvider = new DaoProvider(countryDao, locationDao, raceDao, runDao, sensorMeasurementDao, skierDao); services.AddSingleton <IRaceService>(new RaceService(daoProvider)); services.AddSingleton <ISkierService>(new SkierService(daoProvider)); services.AddSingleton <ILocationService>(new LocationService(daoProvider)); services.AddSingleton <IRunService>(new RunService(daoProvider, new SimulatorRaceClock())); services.AddSingleton <ICountryService>(new CountryService(daoProvider)); services.AddCors(options => options.AddPolicy("CORS", builder => builder.WithOrigins("http://localhost:4200").AllowAnyMethod().AllowAnyHeader())); }
public async Task GetCountryFromLocation() { var location = (await LocationDao.FindAllAsync()).First(); Assert.AreEqual("AUT", location.Country?.CountryCode); }
public void Setup() { _tested = new LocationDao(); }
//public static List<LocationDto> GetLocations(string path) //{ // var result = LocationDao.GetLocations(path); // SortBýpecialistAndName(result, true); // return result; //} public static List <LocationDto> GetLocations2(string path) { var result = LocationDao.GetLocations2(path); return(result); }
public static string Add(string path, LocationDto location) { return(LocationDao.AddLocation(path, location)); }
public static bool Update(string path, LocationDto location) { return(LocationDao.UpdateLocation(path, location)); }
public static bool Delete(string path, string id) { return(LocationDao.DeleteLocation(path, id)); }
public async Task GetPossibleDisciplinesTest() { var location = (await LocationDao.FindAllAsync()).First(); Assert.AreEqual(2, (await LocationDao.GetPossibleDisciplinesForLocation(location.Id)).Count()); }
public async Task FindByIdTest() { var location = (await LocationDao.FindAllAsync()).First(); Assert.AreEqual(location.LocationName, (await LocationDao.FindByIdAsync(location.Id))?.LocationName); }
public async Task FindAllTest() { Assert.AreEqual(1, (await LocationDao.FindAllAsync()).Count()); }
public void DeleteAllTest() { Assert.ThrowsAsync <SqlException>(async() => await LocationDao.DeleteAllAsync()); }