예제 #1
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));
        }