public async Task GetMembers_Invalid_Test(int id) { _cityService.Setup(cs => cs.GetCityMembersAsync(It.IsAny <int>())) .ReturnsAsync(() => null); _mapper.Setup(m => m.Map <CityProfileDTO, CityViewModel>(It.IsAny <CityProfileDTO>())) .Returns(new CityViewModel()); CitiesController cityController = CreateCityController; var result = await cityController.GetMembers(id); Assert.IsNotNull(result); Assert.IsInstanceOf <NotFoundResult>(result); }
public async Task GetMembers_Valid_Test(int id) { // Arrange _cityService .Setup(cs => cs.GetCityMembersAsync(It.IsAny <int>())) .ReturnsAsync(new CityProfileDTO()); _mapper .Setup(m => m.Map <CityProfileDTO, CityViewModel>(It.IsAny <CityProfileDTO>())) .Returns(new CityViewModel()); CitiesController cityController = CreateCityController; // Act var result = await cityController.GetMembers(id); // Assert _mapper.Verify(m => m.Map <CityProfileDTO, CityViewModel>(It.IsAny <CityProfileDTO>())); Assert.IsInstanceOf <OkObjectResult>(result); Assert.NotNull(result); }