Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
0
        public async Task FindByIdTest()
        {
            var country     = (await CountryDao.FindAllAsync()).First();
            var countryById = await CountryDao.FindByIdAsync(country.Id);

            Assert.AreEqual(country.CountryCode, countryById?.CountryCode);
            Assert.AreEqual(country.CountryName, countryById?.CountryName);
        }
Ejemplo n.º 4
0
        public async Task DeleteAllTest()
        {
            await DbTeardown();

            var countryId = await CountryDao.InsertGetIdAsync(new Country { CountryName = "ABC", CountryCode = "DF" });

            await CountryDao.DeleteAllAsync();

            Assert.IsEmpty(await CountryDao.FindAllAsync());
        }
Ejemplo n.º 5
0
        public async Task UpdateTest()
        {
            var country = (await CountryDao.FindAllAsync()).First();

            country.CountryName = "TestABC";
            await CountryDao.UpdateAsync(country);

            var updatedCountry = await CountryDao.FindByIdAsync(country.Id);

            Assert.AreEqual(country.CountryName, updatedCountry?.CountryName);
        }
Ejemplo n.º 6
0
        public async Task InsertTest()
        {
            var countryId  = (await CountryDao.FindAllAsync()).First().Id;
            var locationId = await LocationDao.InsertGetIdAsync(new Location
            {
                CountryId    = countryId,
                LocationName = "Name"
            });

            Assert.AreEqual("Name", (await LocationDao.FindByIdAsync(locationId.Value))?.LocationName);
            Assert.NotNull((await LocationDao.FindByIdAsync(locationId.Value))?.Country);
        }
Ejemplo n.º 7
0
        public async Task DeleteTest()
        {
            var id = await LocationDao.InsertGetIdAsync(new Location
            {
                CountryId    = (await CountryDao.FindAllAsync()).First().Id,
                LocationName = "AAA"
            });

            await LocationDao.DeleteAsync(id.Value);

            Assert.IsNull(await LocationDao.FindByIdAsync(id.Value));
        }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
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());
        }
Ejemplo n.º 10
0
        public async Task FindAllTest()
        {
            var countries = await CountryDao.FindAllAsync();

            Assert.AreEqual(12, countries.Count());
        }