public async Task GetAdministrationByIdAsync_ReturnsAdministrations()
        {
            // Arrange
            _repoWrapper
            .Setup(r => r.CityAdministration.GetAllAsync(It.IsAny <Expression <Func <CityAdministration, bool> > >(),
                                                         It.IsAny <Func <IQueryable <CityAdministration>, IIncludableQueryable <CityAdministration, object> > >()))
            .ReturnsAsync(new List <CityAdministration> {
                new CityAdministration()
                {
                    ID = fakeId
                }
            });
            _mapper
            .Setup(m => m.Map <IEnumerable <CityAdministration>, IEnumerable <CityAdministrationDTO> >(It.IsAny <IEnumerable <CityAdministration> >()))
            .Returns(new List <CityAdministrationDTO> {
                new CityAdministrationDTO {
                    ID = fakeId, AdminType = new AdminTypeDTO(), User = new CityUserDTO()
                }
            });

            // Act
            var result = await _cityParticipantsService.GetAdministrationByIdAsync(It.IsAny <int>());

            // Assert
            Assert.NotNull(result);
            Assert.NotNull(result.Select(admin => admin.User));
            Assert.NotNull(result.Select(admin => admin.AdminType));
            Assert.AreEqual(result.FirstOrDefault().ID, fakeId);
        }
Ejemplo n.º 2
0
 public async Task <IActionResult> GetAdmins(int cityId)
 {
     if (cityId != 0)
     {
         return(Ok(await _cityAdministrationService.GetAdministrationByIdAsync(cityId)));
     }
     _loggerService.LogError("City id is 0");
     return(BadRequest());
 }