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);
        }
Exemple #2
0
        protected TestBase()
        {
            var config  = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
            var section = config.GetSection("ConnectionStrings").GetSection("huraceTest");

            var provider         = section["ProviderName"];
            var connectionString = section["ConnectionString"];

            ConnectionFactory =
                new ConcreteConnectionFactory(DbUtil.GetProviderFactory(provider), connectionString);

            RaceDao        = new RaceDao(ConnectionFactory, StatementFactory);
            SeasonDao      = new SeasonDao(ConnectionFactory, StatementFactory);
            LocationDao    = new LocationDao(ConnectionFactory, StatementFactory);
            CountryDao     = new CountryDao(ConnectionFactory, StatementFactory);
            DisciplineDao  = new DisciplineDao(ConnectionFactory, StatementFactory);
            SkierDao       = new SkierDao(ConnectionFactory, StatementFactory);
            StartListDao   = new StartListDao(ConnectionFactory, StatementFactory);
            RaceEventDao   = new RaceEventDao(ConnectionFactory, StatementFactory);
            SkierEventDao  = new SkierEventDao(ConnectionFactory, StatementFactory);
            TimeDataDao    = new TimeDataDao(ConnectionFactory, StatementFactory);
            GenderDao      = new GenderDao(ConnectionFactory, StatementFactory);
            SensorDao      = new SensorDao(ConnectionFactory, StatementFactory);
            RaceDataDao    = new RaceDataDao(ConnectionFactory, StatementFactory);
            RaceStateDao   = new RaceStateDao(ConnectionFactory, StatementFactory);
            StartStateDao  = new StartStateDao(ConnectionFactory, StatementFactory);
            EventTypeDao   = new EventTypeDao(ConnectionFactory, StatementFactory);
            _dataGenerator = new DataGenerator.Core.DataGenerator(provider, connectionString);
        }
        public async Task GetTimeDataForStartListTest()
        {
            var startList = (await StartListDao.FindAllAsync()).First();

            Assert.AreEqual(
                2, (await TimeDataDao.GetTimeDataForStartList(startList.SkierId, startList.RaceId)).Count());
        }
        public async Task GetNextSkierTest()
        {
            var startList = (await StartListDao.FindAllAsync()).First();

            startList.StartStateId = (int)Domain.Enums.StartState.Upcoming;
            await StartListDao.UpdateAsync(startList);

            Assert.AreEqual(startList.SkierId, (await StartListDao.GetNextSkierForRace(startList.RaceId))?.SkierId);
        }
        public async Task UpdateTest()
        {
            var startList = (await StartListDao.FindAllAsync()).First();

            startList.StartNumber = 999;
            await StartListDao.UpdateAsync(startList);

            Assert.AreEqual(startList.StartNumber,
                            (await StartListDao.FindByIdAsync(startList.SkierId, startList.RaceId))?.StartNumber);
        }
        public async Task GetDisqualifiedSkierForRaceTest()
        {
            var startList = (await StartListDao.FindAllAsync()).First();

            startList.StartStateId = 4;
            await StartListDao.UpdateAsync(startList);

            Assert.IsTrue(
                (await StartListDao.GetDisqualifiedSkierForRace(startList.RaceId)).Any(
                    s => s.SkierId == startList.SkierId));
        }
        public async Task FindByIdTest()
        {
            var startList     = (await StartListDao.FindAllAsync()).First();
            var startListById = await StartListDao.FindByIdAsync(startList.SkierId, startList.RaceId);

            Assert.NotNull(startListById);
            Assert.NotNull(startListById.Race);
            Assert.NotNull(startListById.Skier);
            Assert.NotNull(startListById.Skier?.Country);
            Assert.NotNull(startListById.Skier?.Gender);
            Assert.NotNull(startListById.StartState);
        }
        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());
        }
        public async Task CountStartListForRaceTest()
        {
            var raceId = (await RaceDao.FindAllAsync()).First().Id;

            Assert.AreEqual(5, await StartListDao.CountStartListForRace(raceId));
        }
 public async Task FindAllTest() => Assert.AreEqual(10, (await StartListDao.FindAllAsync()).Count());
        public async Task GetSkierForRaceTest()
        {
            var startList = (await StartListDao.FindAllAsync()).First();

            Assert.AreEqual(startList.SkierId, (await StartListDao.FindByIdAsync(startList.SkierId, startList.RaceId)).SkierId);
        }