Пример #1
0
        public async Task GetAllWithReviewsAsync_WhenFailed_Returns500()
        {
            _beerService.GetAllWithReviewsAsync().Throws(new Exception());

            var response = await _controller.GetAllWithReviewsAsync();

            var statusCodeResult = response.Result as StatusCodeResult;

            Assert.AreEqual((HttpStatusCode)statusCodeResult.StatusCode, HttpStatusCode.InternalServerError);
        }
Пример #2
0
 public async Task <ActionResult <List <Beer> > > GetAllWithReviewsAsync()
 {
     try
     {
         _logger.Information("Getting all beers with reviews.");
         return(await _beerService.GetAllWithReviewsAsync());
     }
     catch (Exception ex)
     {
         _logger.Error(ex, "Request to get all beers with reviews failed.");
         return(StatusCode(500));
     }
 }