public void PlayerCanRemoveAFriendRequest() { authHelper.loginToAccount("userOne"); SendFriendRequestRequest request = new SendFriendRequestRequest() { FriendId = authHelper.getAccountId("userTwo") }; SendFriendRequestResponse response = client.SendFriendRequest(request); Assert.AreEqual(response.Status.IsSuccess, true); authHelper.loginToAccount("userTwo"); DenyFriendRequestRequest friendRequest = new DenyFriendRequestRequest() { FriendId = authHelper.getAccountId("userOne"), }; DenyFriendRequestResponse acceptResponse = client.DenyFriendRequest(friendRequest); Assert.AreEqual(acceptResponse.Status.IsSuccess, true); ViewFriendRequestsResponse friendResponse = client.ViewFriendRequests(new ViewFriendRequestsRequest()); Assert.AreEqual(friendResponse.Status.IsSuccess, true); Assert.AreEqual(0, friendResponse.IncomingFriends.Count); }
public void BlockingAPlayerAfterSendingThemAFriendRequestRemovesTheFriendRequest() { authHelper.loginToAccount("userOne"); SendFriendRequestRequest request = new SendFriendRequestRequest() { FriendId = authHelper.getAccountId("userTwo") }; SendFriendRequestResponse response = client.SendFriendRequest(request); Assert.AreEqual(response.Status.IsSuccess, true); BlockPlayerRequest blockRequest = new BlockPlayerRequest() { UserIdToBlock = authHelper.getAccountId("userTwo") }; client.BlockPlayer(blockRequest); authHelper.loginToAccount("userTwo"); // Make sure the players are not friends. ViewFriendRequestsResponse blockFriendListResponse = client.ViewFriendRequests(new ViewFriendRequestsRequest()); Assert.AreEqual(blockFriendListResponse.Status.IsSuccess, true); Assert.AreEqual(0, blockFriendListResponse.IncomingFriends.Count); }
public override async Task <ViewFriendRequestsResponse> ViewFriendRequests(ViewFriendRequestsRequest request, ServerCallContext context) { RedisUserModel user = context.UserState["user"] as RedisUserModel; if (user == null) { return new ViewFriendRequestsResponse() { Status = ResponseFactory.createResponse(ResponseType.UNAUTHORIZED) } } ; ViewFriendRequestsResponse response = new ViewFriendRequestsResponse(); List <User> users = (await user.GetFriendRequests()).ConvertAll(input => input.asUser()); response.IncomingFriends.AddRange(users); response.Status = ResponseFactory.createResponse(ResponseType.SUCCESS); return(response); }
public void WhenAPlayerGetsAFriendRequestTheyCanSeeIt() { authHelper.loginToAccount("userOne"); SendFriendRequestRequest request = new SendFriendRequestRequest() { FriendId = authHelper.getAccountId("userTwo") }; SendFriendRequestResponse response = client.SendFriendRequest(request); Assert.AreEqual(response.Status.IsSuccess, true); authHelper.loginToAccount("userTwo"); ViewFriendRequestsResponse friendRequestresponse = client.ViewFriendRequests(new ViewFriendRequestsRequest()); Assert.AreEqual(friendRequestresponse.Status.IsSuccess, true); Assert.AreEqual(1, friendRequestresponse.IncomingFriends.Count); Assert.IsTrue(friendRequestresponse.IncomingFriends.Any((user) => user.Id == authHelper.getAccountId("userOne"))); }
public override async Task <ViewFriendRequestsResponse> ViewFriendRequests(ViewFriendRequestsRequest request, ServerCallContext context) { DbUserModel dbUserModel = context.UserState["user"] as DbUserModel; if (dbUserModel == null) { return new ViewFriendRequestsResponse() { Status = ResponseFactory.createResponse(ResponseType.UNAUTHORIZED) } } ; ViewFriendRequestsResponse response = new ViewFriendRequestsResponse(); var friendRequests = await Task.WhenAll( (await dbUserModel.GetFriendRequests()) .Select(async it => (await DbUserModel.GetUserFromGuid(it.FriendId)).AsUser()) ); response.IncomingFriends.AddRange(friendRequests); response.Status = ResponseFactory.createResponse(ResponseType.SUCCESS); return(response); }