Exemple #1
0
        public async Task GetUsersDailyStatisticAsync()
        {
            //Prepare test
            reportsRepositoryMock
            .Setup(r => r.GetItemsAsync(
                       It.IsAny <Expression <Func <DailyReport, bool> > >(),
                       null,
                       "User"))
            .ReturnsAsync(new List <DailyReport>
            {
                new DailyReport {
                    ReportDate = DateTime.Today, User = new User {
                        BodyTypeId = 1, Name = "User1", Surname = "TestUser1"
                    }
                },
                new DailyReport {
                    ReportDate = DateTime.Today, User = new User {
                        BodyTypeId = 1, Name = "User2", Surname = "TestUser2"
                    }
                },
                new DailyReport {
                    ReportDate = DateTime.Today, User = new User {
                        BodyTypeId = 2, Name = "User3", Surname = "TestUser3"
                    }
                }
            });

            //Do test
            var result = await adminReportService.GetUsersDailyStatisticAsync(DateTime.Today);

            //Assert
            calculationsServiceMock.Verify(x => x.CalculateGroupsAverages(It.IsAny <IEnumerable <GroupStatistic> >()), Times.Once);

            Assert.Equal(2, result.Count());
            Assert.Equal(2, result.First().Values.Count());
            Assert.Single(result.Last().Values);
            Assert.Equal(TypeOfBody.Ectomorph, result.First().Key);
            Assert.Equal(TypeOfBody.Endomorph, result.Last().Key);
        }
 public async Task <IEnumerable <GroupStatistic> > GetDailyStatistic(DateTime reportDate)
 {
     return(await _reportService.GetUsersDailyStatisticAsync(reportDate));
 }