Example #1
0
        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>();
        }
Example #2
0
        public async void TestFindById()
        {
            ConnectionFactory     connectionFactory    = new ConnectionFactory(Environment.Testing);
            ISensorMeasurementDao sensorMeasurementDao = new SensorMeasurementDao(connectionFactory);

            SensorMeasurement sensorMeasurement = await InsertSensorMeasurement(connectionFactory);

            SensorMeasurement sensorMeasurementFound = await sensorMeasurementDao.FindById(sensorMeasurement.Id);

            Assert.Equal(sensorMeasurement.Timestamp, sensorMeasurementFound.Timestamp);
        }
Example #3
0
        public async void TestDelete()
        {
            ConnectionFactory     connectionFactory    = new ConnectionFactory(Environment.Testing);
            ISensorMeasurementDao sensorMeasurementDao = new SensorMeasurementDao(connectionFactory);

            SensorMeasurement sensorMeasurement = await InsertSensorMeasurement(connectionFactory);

            Assert.NotNull(await sensorMeasurementDao.FindById(sensorMeasurement.Id));

            await sensorMeasurementDao.Delete(sensorMeasurement.Id);

            Assert.Null(await sensorMeasurementDao.FindById(sensorMeasurement.Id));
        }
Example #4
0
        public async void TestUpdate()
        {
            ConnectionFactory     connectionFactory    = new ConnectionFactory(Environment.Testing);
            ISensorMeasurementDao sensorMeasurementDao = new SensorMeasurementDao(connectionFactory);

            SensorMeasurement sensorMeasurement = await InsertSensorMeasurement(connectionFactory);

            sensorMeasurement.Timestamp = 1576850015.2222;
            await sensorMeasurementDao.Update(sensorMeasurement);

            SensorMeasurement sensorMeasurementAfter = await sensorMeasurementDao.FindById(sensorMeasurement.Id);

            Assert.Equal(sensorMeasurement.Timestamp, sensorMeasurementAfter.Timestamp);
        }
Example #5
0
        public async void TestFindAll()
        {
            ConnectionFactory     connectionFactory    = new ConnectionFactory(Environment.Testing);
            ISensorMeasurementDao sensorMeasurementDao = new SensorMeasurementDao(connectionFactory);

            foreach (var _ in await sensorMeasurementDao.FindAll())
            {
                Assert.True(false, "FindAll should return an empty collection");
            }

            await InsertSensorMeasurement(connectionFactory);

            foreach (var _ in await sensorMeasurementDao.FindAll())
            {
                return;
            }
            Assert.True(false, "FindAll should return a non-empty collection");
        }
Example #6
0
        public static async Task <SensorMeasurement> InsertSensorMeasurement(ConnectionFactory connectionFactory,
                                                                             Run run = null)
        {
            ISensorMeasurementDao sensorMeasurementDao = new SensorMeasurementDao(connectionFactory);

            run ??= await RunDaoTests.InsertRun(connectionFactory);

            SensorMeasurement sensorMeasurement = new SensorMeasurement
            {
                SensorId  = 1,
                Timestamp = 1576850015.1111,
                Run       = run,
            };

            sensorMeasurement.Id = await sensorMeasurementDao.Insert(sensorMeasurement);

            return(sensorMeasurement);
        }
Example #7
0
        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()));
        }