Esempio n. 1
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. 2
0
        public async Task InsertTest()
        {
            var skierId = (await SkierDao.FindAllAsync()).First().Id;
            var raceId  = (await RaceDao.FindAllAsync()).First().Id;

            var newSkierId = await SkierDao.InsertGetIdAsync(new Skier
            {
                Retired     = false,
                CountryId   = (await CountryDao.FindAllAsync()).First().Id,
                FirstName   = "ABC",
                LastName    = "DEF",
                GenderId    = 1,
                DateOfBirth = DateTime.Now
            });

            await StartListDao.InsertAsync(new StartList
            {
                SkierId      = newSkierId.Value,
                RaceId       = raceId,
                StartNumber  = 99,
                StartStateId = (int)Domain.Enums.RaceState.Finished
            });

            var startList = await StartListDao.FindByIdAsync(skierId, raceId);

            Assert.AreEqual(skierId, startList.SkierId);
            Assert.AreEqual(raceId, startList.RaceId);
            Assert.AreEqual((int)Domain.Enums.RaceState.Finished, startList.StartStateId);
            Assert.NotNull(startList.Skier);
            Assert.NotNull(startList.StartState);
            Assert.NotNull(startList.Race);
        }
Esempio n. 3
0
        public async Task FindAvailableSkiersForRaceTest()
        {
            var skier = (await SkierDao.FindAllAsync()).First();
            var race  = (await RaceDao.FindAllAsync()).First();

            var availableSkiers = await SkierDao.FindAvailableSkiersForRace(race.Id);

            Assert.IsTrue(availableSkiers.All(s => s.Id != skier.Id));


            var newSkierId = await SkierDao.InsertGetIdAsync(new Skier
            {
                Retired     = false,
                FirstName   = "xy",
                LastName    = "z",
                CountryId   = (await CountryDao.FindAllAsync()).First().Id,
                GenderId    = race.GenderId,
                DateOfBirth = DateTime.Today
            });

            availableSkiers = await SkierDao.FindAvailableSkiersForRace(race.Id);

            Assert.IsTrue(availableSkiers.All(s => s.Id != newSkierId.Value));

            var newSkier = await SkierDao.FindByIdAsync(newSkierId.Value);

            newSkier.GenderId = newSkier.GenderId == 1 ? 2 : 1;

            await SkierDao.UpdateAsync(newSkier);

            availableSkiers = await SkierDao.FindAvailableSkiersForRace(race.Id);

            Assert.IsFalse(availableSkiers.Any(s => s.Id != newSkierId.Value));
        }
Esempio n. 4
0
        public async Task GetRankingForSensorTest()
        {
            var race    = (await RaceDao.FindAllAsync()).First();
            var ranking = (await TimeDataDao.GetRankingForSensor(race.Id, 1)).ToList();

            Assert.AreEqual(5, ranking.Count());
            Assert.IsTrue(ranking[0].Time < ranking[1].Time);
        }
Esempio n. 5
0
        public async Task GetActiveRaceByIdTest()
        {
            var race = (await RaceDao.FindAllAsync()).First();

            race.RaceStateId = 2;
            await RaceDao.UpdateAsync(race);

            Assert.NotNull(await RaceDao.GetActiveRaceById(race.Id));
        }
Esempio n. 6
0
        public async Task UpdateTest()
        {
            var race = (await RaceDao.FindAllAsync()).First();

            race.RaceDescription = "Test123";
            await RaceDao.UpdateAsync(race);

            Assert.AreEqual(race.RaceDescription, (await RaceDao.FindByIdAsync(race.Id))?.RaceDescription);
        }
Esempio n. 7
0
        public async Task GetActiveRacesTest()
        {
            var race = (await RaceDao.FindAllAsync()).First();

            race.RaceStateId = 2;
            await RaceDao.UpdateAsync(race);

            Assert.AreEqual(1, (await RaceDao.GetActiveRaces()).Count());
        }
Esempio n. 8
0
        public async Task FindByIdTest()
        {
            var race     = (await RaceDao.FindAllAsync()).First();
            var raceById = await RaceDao.FindByIdAsync(race.Id);

            Assert.AreEqual(race.RaceDescription, raceById?.RaceDescription);
            Assert.NotNull(raceById?.Gender);
            Assert.NotNull(raceById?.Location);
            Assert.NotNull(raceById?.Season);
            Assert.NotNull(raceById?.RaceState);
        }
Esempio n. 9
0
        public async Task DeleteTest()
        {
            var raceDataId = await RaceDataDao.InsertGetIdAsync(new RaceData
            {
                RaceId        = (await RaceDao.FindAllAsync()).First().Id,
                EventDateTime = DateTime.Now,
                EventTypeId   = (await EventTypeDao.FindAllAsync()).First().Id
            });

            await RaceDataDao.DeleteAsync(raceDataId.Value);

            Assert.IsNull(await RaceDataDao.FindByIdAsync(raceDataId.Value));
        }
Esempio n. 10
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. 11
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. 12
0
        public async Task GetAverageTimeForSensorTest()
        {
            var race      = (await RaceDao.FindAllAsync()).First();
            var timeDatas = await TimeDataDao.FindAllAsync();

            var tasks = timeDatas.Where(t => t.RaceId == race.Id && t.Sensor.SensorNumber == 1).Select(
                async t =>
            {
                t.Time = 1500;
                await TimeDataDao.UpdateAsync(t);
            });
            await Task.WhenAll(tasks);

            Assert.AreEqual(1500, await TimeDataDao.GetAverageTimeForSensor(race.Id, 1));
        }
Esempio n. 13
0
        public async Task InsertTest()
        {
            var raceId     = (await RaceDao.FindAllAsync()).First().Id;
            var raceDataId = await RaceDataDao.InsertGetIdAsync(new RaceData
            {
                RaceId        = raceId,
                EventDateTime = new DateTime(1969, 4, 20),
                EventTypeId   = (int)Domain.Enums.RaceDataEvent.RaceFinished
            });

            var raceDataById = await RaceDataDao.FindByIdAsync(raceDataId.Value);

            Assert.AreEqual(raceId, raceDataById.RaceId);
            Assert.AreEqual(new DateTime(1969, 4, 20), raceDataById.EventDateTime);
            Assert.AreEqual((int)Domain.Enums.RaceDataEvent.RaceFinished, raceDataById.EventTypeId);
        }
Esempio n. 14
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. 15
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. 16
0
        public async Task GetRemainingStartListForRaceTest()
        {
            var race = (await RaceDao.FindAllAsync()).First();

            Assert.AreEqual(0, (await StartListDao.GetRemainingStartListForRace(race.Id)).Count());

            var skierId = await SkierDao.InsertGetIdAsync(new Skier
            {
                Retired     = false,
                FirstName   = "F",
                LastName    = "S",
                CountryId   = (await CountryDao.FindAllAsync()).First().Id,
                GenderId    = race.GenderId,
                DateOfBirth = DateTime.Now
            });

            await StartListDao.InsertAsync(new StartList
            {
                RaceId = race.Id, SkierId = skierId.Value, StartNumber = 99, StartStateId = (int)StartState.Upcoming
            });

            Assert.AreEqual(1, (await StartListDao.GetRemainingStartListForRace(race.Id)).Count());
        }
Esempio n. 17
0
 public async Task FindAllTest() => Assert.AreEqual(2, (await RaceDao.FindAllAsync()).Count());
Esempio n. 18
0
        public async Task CountStartListForRaceTest()
        {
            var raceId = (await RaceDao.FindAllAsync()).First().Id;

            Assert.AreEqual(5, await StartListDao.CountStartListForRace(raceId));
        }
Esempio n. 19
0
        public async Task GetLastSensorNumberTest()
        {
            var race = (await RaceDao.FindAllAsync()).First();

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

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

            Assert.AreEqual(10, await TimeDataDao.CountTimeDataForRace(race.Id));
        }