public async Task E_Possivel_Executar_Metodo_Get_Complete_by_Id() { _serviceMock = new Mock <IMunicipioService>(); _serviceMock.Setup(m => m.GetCompleteById(IdMunicipio)).ReturnsAsync(municipioDtoCompleto); _service = _serviceMock.Object; var result = await _service.GetCompleteById(IdMunicipio); Assert.NotNull(result); Assert.True(result.Id == IdMunicipio); Assert.Equal(Cidade, result.Cidade); Assert.NotNull(result.Uf); }
public async Task Execute_GETComplete() { _serviceMock = new Mock <IMunicipioService>(); _serviceMock.Setup(m => m.GetCompleteById(IdMunicipio)).ReturnsAsync(municipioDtoCompleto); _service = _serviceMock.Object; var result = await _service.GetCompleteById(IdMunicipio); Assert.NotNull(result); Assert.True(result.Id == IdMunicipio); Assert.Equal(NomeMunicipio, result.Nome); Assert.Equal(CodigoIBGEMunicipio, result.CodeIBGE); Assert.NotNull(result.Uf); }
public async Task <ActionResult> GetCompleteById(Guid id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); //400 bad request - solicitacao inválida } try { var result = await _service.GetCompleteById(id); if (result == null) { return(NotFound()); } return(Ok(result)); } catch (ArgumentException e) { return(StatusCode((int)HttpStatusCode.InternalServerError, e.Message)); } }