Exemple #1
0
        public async Task GetDietStatsAsync_ShouldReturnAthleteDietStats(int userId)
        {
            var dietStat = _fixture.Create <DietStat>();

            var athleteDietStats = new List <AthleteDietStats>()
            {
                new AthleteDietStats
                {
                    Id          = 1,
                    DateCreated = DateTime.Now,
                    DateUpdated = DateTime.Now,
                    UserId      = userId,
                    DietStat    = dietStat
                }
            };

            var athlete = _fixture.Build <Athlete>()
                          .With(a => a.UserId, userId)
                          .With(a => a.AthleteDietStats, athleteDietStats)
                          .Without(a => a.AthleteExercises)
                          .Create();

            _athleteRepository.FindByCondition(Arg.Any <Expression <Func <Athlete, bool> > >(),
                                               Arg.Any <Func <IQueryable <Athlete>, IIncludableQueryable <Athlete, object> > >()).ReturnsForAnyArgs(athlete);


            var dto = await _sut.GetDietStatsAsync(athlete.UserId, new DateTime());

            dto.ShouldNotBeNull();
            dto.UserId.ShouldBe(athlete.UserId);
            dto.DietStats.Count.ShouldBe(1);
            dto.DietStats.First().DietStat.TotalCalories = dietStat.TotalCalories;
            dto.DietStats.First().DietStat.TotalProteins = dietStat.TotalProteins;
            dto.DietStats.First().DietStat.TotalCarbohydrates = dietStat.TotalCarbohydrates;
            dto.DietStats.First().DietStat.TotalFats = dietStat.TotalFats;
        }
 public async Task <AthleteDto> HandleAsync(GetDietStats query)
 {
     return(await _athleteDietStatsService.GetDietStatsAsync(query.UserId, query.Date));
 }