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)); }
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); }
public async Task DeleteAllPossibleDisciplineTest() { var skierId = (await SkierDao.FindAllAsync()).First().Id; await SkierDao.DeleteAllPossibleDisciplineForSkier(skierId); Assert.AreEqual(0, (await SkierDao.GetPossibleDisciplinesForSkier(skierId)).Count()); }
public async Task UpdateTest() { var skier = (await SkierDao.FindAllAsync()).First(); skier.FirstName = "Testname"; await SkierDao.UpdateAsync(skier); Assert.AreEqual(skier.FirstName, (await SkierDao.FindByIdAsync(skier.Id))?.FirstName); }
public async Task FindByIdTest() { var id = (await SkierDao.FindAllAsync()).First().Id; var skier = await SkierDao.FindByIdAsync(id); Assert.NotNull(skier); Assert.NotNull(skier?.Country); Assert.NotNull(skier?.Gender); }
public async Task UpdateTest() { var skierEvent = (await SkierEventDao.FindAllAsync()).First(); var skierId = (await SkierDao.FindAllAsync()).First().Id; skierEvent.SkierId = skierId; await SkierEventDao.UpdateAsync(skierEvent); Assert.AreEqual(skierEvent.SkierId, (await SkierEventDao.FindByIdAsync(skierEvent.Id))?.SkierId); }
public async Task AddPossibleDisciplineTest() { var disciplineId = await DisciplineDao.InsertGetIdAsync(new Discipline { DisciplineName = "TestDiscipline" }); var skierId = (await SkierDao.FindAllAsync()).First().Id; await SkierDao.InsertPossibleDisciplineForSkier(skierId, disciplineId.Value); Assert.AreEqual(3, (await SkierDao.GetPossibleDisciplinesForSkier(skierId)).Count()); }
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); }
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"); } }
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); }
public async Task GetPossibleDisciplinesTest() { var id = (await SkierDao.FindAllAsync()).First().Id; Assert.AreEqual(2, (await SkierDao.GetPossibleDisciplinesForSkier(id)).Count()); }
public async Task FindAllTest() => Assert.AreEqual(5, (await SkierDao.FindAllAsync()).Count());