Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public async Task GetSensorForSensorNumberTest()
        {
            var race   = (await RaceDao.FindAllAsync()).First();
            var sensor = (await SensorDao.FindAllSensorsForRace(race.Id)).First();

            Assert.AreEqual(sensor.Id, (await SensorDao.GetSensorForSensorNumber(sensor.SensorNumber, race.Id)).Id);
        }
Esempio n. 3
0
        public async Task UpdateTest()
        {
            var sensor = (await SensorDao.FindAllAsync()).First();

            sensor.SensorNumber = 1;
            await SensorDao.UpdateAsync(sensor);

            Assert.AreEqual(sensor.SensorNumber, (await SensorDao.FindByIdAsync(sensor.Id))?.SensorNumber);
        }
Esempio n. 4
0
        public async Task FindByIdTest()
        {
            var skier    = (await SkierDao.FindAllAsync()).First();
            var race     = (await RaceDao.FindAllAsync()).First();
            var sensor   = (await SensorDao.FindAllAsync()).First();
            var timeData = await TimeDataDao.FindByIdAsync(skier.Id, race.Id, sensor.Id);

            Assert.NotNull(timeData);
            Assert.NotNull(timeData.StartList);
            Assert.NotNull(timeData?.SkierEvent);
            Assert.NotNull(timeData?.SkierEvent?.RaceData);
            Assert.NotNull(timeData?.Sensor);
            Assert.AreEqual(DateTime.Today.Millisecond, timeData?.Time);
        }
Esempio n. 5
0
        public async Task InsertTest()
        {
            var raceId = (await RaceDao.FindAllAsync()).First().Id;
            var id     = await SensorDao.InsertGetIdAsync(new Sensor
            {
                RaceId       = raceId,
                SensorNumber = 21
            });

            var sensor = await SensorDao.FindByIdAsync(id.Value);

            Assert.AreEqual(21, sensor.SensorNumber);
            Assert.AreEqual(raceId, sensor.RaceId);
        }
Esempio n. 6
0
        public async Task UpdateTest()
        {
            var skier    = (await SkierDao.FindAllAsync()).First();
            var race     = (await RaceDao.FindAllAsync()).First();
            var sensor   = (await SensorDao.FindAllAsync()).First();
            var timeData = await TimeDataDao.FindByIdAsync(skier.Id, race.Id, sensor.Id);

            if (timeData != null)
            {
                timeData.Time = 500;
                await TimeDataDao.UpdateAsync(timeData);

                timeData = await TimeDataDao.FindByIdAsync(skier.Id, race.Id, sensor.Id);

                Assert.AreEqual(500, timeData?.Time);
            }
            else
            {
                Assert.Fail("TimeData was null");
            }
        }
Esempio n. 7
0
        public async Task InsertTest()
        {
            var skier        = (await SkierDao.FindAllAsync()).First();
            var race         = (await RaceDao.FindAllAsync()).First();
            var skierEventId = (await SkierEventDao.FindAllAsync()).First().Id;
            var newSensorId  =
                await SensorDao.InsertGetIdAsync(new Sensor { RaceId = race.Id, SensorNumber = 0 });

            await TimeDataDao.InsertAsync(new TimeData
            {
                SkierEventId = skierEventId,
                RaceId       = race.Id,
                SensorId     = newSensorId.Value,
                Time         = new DateTime(2019, 11, 6).Millisecond,
                SkierId      = skier.Id
            });

            var timeData = await TimeDataDao.FindByIdAsync(skier.Id, race.Id, newSensorId.Value);

            Assert.NotNull(timeData);
            Assert.AreEqual(new DateTime(2019, 11, 6).Millisecond, timeData?.Time);
        }
Esempio n. 8
0
 public SensorService(SensorDao sensorDao)
 {
     _sensorDao = sensorDao;
 }
Esempio n. 9
0
        public async Task GetLastSensorNumberTest()
        {
            var race = (await RaceDao.FindAllAsync()).First();

            Assert.AreEqual(1, await SensorDao.GetLastSensorNumber(race.Id));
        }
Esempio n. 10
0
        public async Task FindAllSensorsForRaceTest()
        {
            var race = (await RaceDao.FindAllAsync()).First();

            Assert.AreEqual(2, (await SensorDao.FindAllSensorsForRace(race.Id)).Count());
        }
Esempio n. 11
0
        public async Task FindByIdTest()
        {
            var id = (await SensorDao.FindAllAsync()).First().Id;

            Assert.NotNull(await SensorDao.FindByIdAsync(id));
        }
Esempio n. 12
0
 public async Task FindAllTest() => Assert.AreEqual(2, (await SensorDao.FindAllAsync()).Count());