public async Task GetById_ReturnsNotFount_WhenNotExist() { A.CallTo(() => _requestStatisticService.GetByIdAsync(Id)) .ThrowsAsync(new EntityNotFoundException <RequestBenchmarkEntryDto>(Id)); var result = await _websiteStatisticController.GetByIdAsync(Id); result.Should().BeNotFoundResult(); }
public async Task <IActionResult> GetByIdAsync(int id) { RequestBenchmarkEntryDto requestDto; try { requestDto = await _websiteSpeedStatisticService.GetByIdAsync(id); } catch (EntityNotFoundException <RequestBenchmarkEntryDto> ) { return(NotFound()); } var viewModel = _mapper.Map <RequestBenchmarkEntryDto, RequestBenchmarkEntryViewModel>(requestDto); _logger.LogDebug($"Reading website performance stats by id: {id}"); return(Ok(viewModel)); }