Exemplo n.º 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));
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        public async Task InsertTest()
        {
            var countryId = (await CountryDao.FindAllAsync()).First().Id;
            var skierId   = await SkierDao.InsertGetIdAsync(new Skier
            {
                CountryId   = countryId,
                FirstName   = "Test",
                LastName    = "pacito",
                GenderId    = (int)Domain.Enums.Gender.Male,
                DateOfBirth = new DateTime(1969, 4, 20)
            });

            var skier = await SkierDao.FindByIdAsync(skierId.Value);

            Assert.AreEqual(countryId, skier.CountryId);
            Assert.AreEqual("Test", skier.FirstName);
            Assert.AreEqual("pacito", skier.LastName);
            Assert.AreEqual((int)Domain.Enums.Gender.Male, skier.GenderId);
            Assert.AreEqual(new DateTime(1969, 4, 20), skier.DateOfBirth);
            Assert.NotNull(skier.Country);
            Assert.NotNull(skier.Gender);
        }