Exemplo n.º 1
0
 public async Task <ActionResult> GetAll()
 {
     try
     {
         return(Ok(await _service.GetAll()));
     }
     catch (ArgumentException e)
     {
         return(StatusCode((int)HttpStatusCode.InternalServerError, e.Message));
     }
 }
Exemplo n.º 2
0
        public async Task E_Possivel_Executar_GetAll()
        {
            _serviceMock = new Mock <ILivroServices>();
            _serviceMock.Setup(c => c.GetAll()).ReturnsAsync(ListLivroDto);
            _service = _serviceMock.Object;

            var result = await _service.GetAll();

            Assert.NotNull(result);

            var listVazia = new List <LivroDto>();

            _serviceMock = new Mock <ILivroServices>();
            _serviceMock.Setup(c => c.GetAll()).ReturnsAsync(listVazia);
            _service = _serviceMock.Object;

            var resultEmpty = await _service.GetAll();

            Assert.Empty(resultEmpty);
        }