public async Task GetEventListAsync_LoadLootThenMapTheResponse() { const int groupId = 8; var loots = new List <Loot>(); var lootsResponse = new List <LootResponse>(); _lootService.GetLootsForGroupAsync(_executionContext, groupId) .Returns(loots); _mapper.Map <List <LootResponse> >(loots) .Returns(lootsResponse); var result = await _controller.GetLootListAsync(_executionContext, groupId); result.Value.Should().BeSameAs(lootsResponse); }
public async Task <ActionResult <List <LootResponse> > > GetLootListAsync( [FromServices] NaheulbookExecutionContext executionContext, [FromRoute] int groupId ) { try { var loots = await _lootService.GetLootsForGroupAsync(executionContext, groupId); return(_mapper.Map <List <LootResponse> >(loots)); } catch (ForbiddenAccessException ex) { throw new HttpErrorException(StatusCodes.Status403Forbidden, ex); } catch (GroupNotFoundException ex) { throw new HttpErrorException(StatusCodes.Status404NotFound, ex); } }