public async Task <IHttpActionResult> GetWall(int wallId) { if (wallId <= 0) { return(BadRequest()); } try { var userAndOrg = GetUserAndOrganization(); var wall = await _wallService.GetWallDetails(wallId, userAndOrg); if (!_permissionService.UserHasPermission(userAndOrg, BasicPermissions.Post) && wall.Type != WallType.Events) { return(Forbidden()); } var mappedWall = _mapper.Map <WallDto, WallListViewModel>(wall); return(Ok(mappedWall)); } catch (ValidationException e) { return(BadRequestWithError(e)); } }
public async Task Wall_GetWall_Should_Return_View_Model() { var wallId = 1; var wall = new WallDto { Id = wallId }; _wallService.GetWall(wallId, null).Returns(new WallDto { Type = WallType.UserCreated }); _wallService.GetWallDetails(0, null).ReturnsForAnyArgs(Task.Run(() => wall)); var response = await _wallController.GetWall(wallId); Assert.IsInstanceOf <OkNegotiatedContentResult <WallListViewModel> >(response); }