示例#1
0
        public async Task GetCityStatistics()
        {
            // Arrange
            _repositoryWrapper.Setup(r => r.City.GetFirstOrDefaultAsync(It.IsAny <Expression <Func <DatabaseEntities.City, bool> > >(),
                                                                        It.IsAny <Func <IQueryable <DatabaseEntities.City>, IIncludableQueryable <DatabaseEntities.City, object> > >()))
            .ReturnsAsync(new DatabaseEntities.City());
            _repositoryWrapper.Setup(r => r.MembersStatistics.GetFirstOrDefaultAsync(It.IsAny <Expression <Func <DatabaseEntities.MembersStatistic, bool> > >(),
                                                                                     It.IsAny <Func <IQueryable <DatabaseEntities.MembersStatistic>, IIncludableQueryable <DatabaseEntities.MembersStatistic, object> > >()))
            .ReturnsAsync(new DatabaseEntities.MembersStatistic());
            _mapper.Setup(m => m.Map <DatabaseEntities.City, DTOs.City>(It.IsAny <DatabaseEntities.City>()))
            .Returns(_cities.First());
            int year           = 2019;
            var expectedResult = new CityStatistics
            {
                City           = _cities.First(),
                YearStatistics = new List <YearStatistics>
                {
                    new YearStatistics {
                        Year = year, StatisticsItems = _expectedStatisticsItems
                    }
                }
            };

            // Act
            var result = await _statisticsService.GetCityStatisticsAsync(It.IsAny <int>(), year, _indicators);

            // Assert
            Assert.Equal(JsonConvert.SerializeObject(expectedResult), JsonConvert.SerializeObject(result));
        }