public async Task <IActionResult> PutAsync(UpdateBeerStyle beerStyle) { IActionResult result = null; try { var style = await _context.BeerStyles.FindAsync(beerStyle.StyleId); if (style != null) { style.StyleName = beerStyle.StyleName; style.DateModified = DateTime.UtcNow; await _context.SaveChangesAsync(); result = Ok(style); } else { result = NotFound(); } } catch (Exception e) { result = BadRequest(); } return(result); }
public async Task PutAsync_Should_Return_BadRequest_On_Exception() { // Arrange UpdateBeerStyle updateRequest = null; // Act var result = await _controller.PutAsync(updateRequest); // Assert result.Should() .NotBeNull(); result.Should() .BeOfType <BadRequestResult>(); }