public async Task GetAdmins_Invalid_Test(int id) { _cityService.Setup(c => c.GetCityAdminsAsync(It.IsAny <int>())) .ReturnsAsync(() => null); _mapper.Setup(m => m.Map <CityProfileDTO, CityViewModel>(It.IsAny <CityProfileDTO>())) .Returns(new CityViewModel()); CitiesController citycon = CreateCityController; var result = await citycon.GetAdmins(id); Assert.NotNull(result); Assert.IsInstanceOf <NotFoundResult>(result); }
public async Task GetAdmins_Valid_Test(int id) { // Arrange _cityService .Setup(c => c.GetCityAdminsAsync(It.IsAny <int>())) .ReturnsAsync(new CityProfileDTO()); _mapper .Setup(m => m.Map <CityProfileDTO, CityViewModel>(It.IsAny <CityProfileDTO>())) .Returns(new CityViewModel()); CitiesController citycon = CreateCityController; // Act var result = await citycon.GetAdmins(id); // Assert _mapper.Verify(m => m.Map <CityProfileDTO, CityViewModel>(It.IsAny <CityProfileDTO>())); Assert.NotNull(result); Assert.IsInstanceOf <OkObjectResult>(result); }