Esempio n. 1
0
        /// <summary>
        /// Creates and returns a list of carEntities in a test repository. The first car always has IsCurrent = true.
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public async Task <List <CarEntity> > CreateCarEntityInTestRepo(string userId, int count = 1)
        {
            int countAddedCarEntities = 0;

            var carEntities = Enumerable.Range(0, count).Select(x =>
            {
                countAddedCarEntities++;

                return(new CarEntity
                {
                    UserId = userId,
                    CarEntityName = _faker.Lorem.Word(),
                    CarsTotalRide = new Random().Next(),
                    IsCurrent = countAddedCarEntities == 1 ? true : false,
                });
            }).ToList();


            foreach (var c in carEntities)
            {
                await _dataRepository.AddUserNewCarAsync(c);
            }

            return(carEntities);
        }