public async Task GetAllCitiesIdAndName_NoRoles() { // Arrange var expectedEmpty = Enumerable.Empty <CityForAdministrationDTO>(); _userManager.Setup(u => u.GetRolesAsync(It.IsAny <User>())) .ReturnsAsync(new List <string>()); _repositoryWrapper.Setup(x => x.AnnualReports.GetAllAsync( It.IsAny <Expression <Func <DatabaseEntities.AnnualReport, bool> > >(), It .IsAny <Func <IQueryable <DatabaseEntities.AnnualReport>, IIncludableQueryable <DatabaseEntities.AnnualReport, object> > >())).ReturnsAsync(new List <DatabaseEntities.AnnualReport>() { new DatabaseEntities.AnnualReport() { CityId = 1 } }); //Act var result = await _cityAccessService.GetAllCitiesIdAndName(It.IsAny <User>()); // Assert _userManager.Verify(u => u.GetRolesAsync(It.IsAny <User>())); Assert.Equal(result, expectedEmpty); }
public async Task <IActionResult> GetCitiesNameThatUserHasAccessTo() { return(Ok(new { cities = await _cityAccessService.GetAllCitiesIdAndName(await _userManager.GetUserAsync(User)) })); }