/// <summary> /// Retrieves the last messages for a user with his friends/following gyms for unit testing /// </summary> /// <param name="actualRequest">the client request to be handled</param> /// <returns>the response to the given request</returns> private ActualRequest GetLastMessagesForUser(ActualRequest actualRequest) { List <int> integers = JsonSerializer.Deserialize <List <int> >(actualRequest.Request.Argument.ToString()); List <UserShortVersionWithMessage> users = chatRepo.GetLastMessagesForUser(integers[0], integers[1]); Request response = new Request { ActionType = ActionType.MESSAGE_GET_LATEST.ToString(), Argument = JsonSerializer.Serialize(users) }; List <byte[]> userAvatars = new List <byte[]>(); if (users != null && users.Count > 0) { foreach (var user in users) { if (user.Message.HasImage) { user.Message.Content = "<Image>"; } try { var readAvatarFile = File.ReadAllBytes($"{FILE_PATH}/Users/{user.UserId}/avatar.jpg"); userAvatars.Add(ImagesUtil.ResizeImage(readAvatarFile, 20, 20)); } catch (Exception e) { Console.WriteLine("No avatar found for user " + user.UserId); } } } return(new ActualRequest { Request = response, Images = userAvatars }); }