public async Task Execute_GetAll() { _serviceMock = new Mock <IUfService>(); _serviceMock.Setup(m => m.GetAll()).ReturnsAsync(listaUfDto); _service = _serviceMock.Object; var _records = await _service.GetAll(); Assert.NotNull(_records); Assert.True(_records.Any()); }
public async Task <ActionResult> GetAll() { if (!ModelState.IsValid) { return(BadRequest(ModelState)); //400 bad request - solicitacao inválida } try { return(Ok(await _service.GetAll())); } catch (ArgumentException e) { return(StatusCode((int)HttpStatusCode.InternalServerError, e.Message)); } }
public async Task E_Possivel_Executar_Metodo_GetAll() { _serviceMock = new Mock <IUfService>(); _serviceMock.Setup(m => m.GetAll()).ReturnsAsync(listaUfDto); _service = _serviceMock.Object; var result = await _service.GetAll(); Assert.NotNull(result); Assert.True(result.Count() == 10); var _listResult = new List <UfDto>(); _serviceMock = new Mock <IUfService>(); _serviceMock.Setup(m => m.GetAll()).ReturnsAsync(_listResult.AsEnumerable); _service = _serviceMock.Object; var _resultEmpty = await _service.GetAll(); Assert.Empty(_resultEmpty); Assert.True(_resultEmpty.Count() == 0); }