public void TestGoogleFriendsXmlGetAttributes() { string xml = @"<roar tick=""128455369786""> <google> <friends status=""ok""> <!-- ""Mashton"" is already playing this game and has an 'id' we can use --> <friend gplus_name=""Mashton Groober"" gplus_id=""51151277315"" name=""Mashton"" id=""7877788777""/> <!-- These other two friends are not playing this game (no 'id' or 'name') --> <friend gplus_name=""Jumpy Maxton"" gplus_id=""529465555""/> <friend gplus_name=""Ami Jones"" gplus_id=""523055555""/> </friends> </google> </roar>" ; System.Xml.XmlElement nn = RoarExtensions.CreateXmlElement(xml); Roar.DataConversion.Responses.Google.Friends friends_parser = new Roar.DataConversion.Responses.Google.Friends(); FriendsResponse response = friends_parser.Build(nn); Assert.AreEqual(response.friends.Count, 3); Assert.AreEqual(response.friends[0].id, "7877788777"); Assert.AreEqual(response.friends[0].name, "Mashton"); Assert.AreEqual(response.friends[0].gplus_id, "51151277315"); Assert.AreEqual(response.friends[0].gplus_name, "Mashton Groober"); Assert.IsNull(response.friends[1].id); Assert.IsNull(response.friends[1].name); Assert.AreEqual(response.friends[1].gplus_id, "529465555"); Assert.AreEqual(response.friends[1].gplus_name, "Jumpy Maxton"); Assert.IsNull(response.friends[2].id); Assert.IsNull(response.friends[2].name); Assert.AreEqual(response.friends[2].gplus_id, "523055555"); Assert.AreEqual(response.friends[2].gplus_name, "Ami Jones"); }
private void OnLogin_FriendsResponse(Datagram datagram) { FriendsResponse res = datagram.UnSerialData <FriendsResponse>(); if (RunningDatas.RequestTable.TryGetValue(datagram.RequestID, out RequestSender value)) { value.RequestCallback(res); } }
private void FriendsCallBack(FriendsResponse response) { for (int i = 0; i < response.FriendsID.Length; ++i) { RunningDatas.DataSender.UserInfoReq(RequestID, new UserGroupInfoReq { ID = response.FriendsID[i] }); } }
private void _dbdLobbyInfoReader_OnKillerInfo(object sender, FriendsResponse e) { Dispatcher.Invoke(() => { var viewContext = (DataContext as WindowViewModel); viewContext.CloudID = e.UserId.ToString(); viewContext.SteamID = e.PlatformIds?.Steam; viewContext.Username = e.FriendPlayerName?.ProviderPlayerNames?.Steam; viewContext.OnPropertyChanged("CloudID"); viewContext.OnPropertyChanged("SteamID"); viewContext.OnPropertyChanged("Username"); }); //throw new NotImplementedException(); }
private void _ParseResponse(string response) { try { FriendsResponse friends = SerializeHelper.Deserialise <FriendsResponse>(response); if (friends.Friends != null) { _callback(friends.Friends); } } catch (Exception) { Debug.WriteLine("Parse response from FriendsGetSuggestions failed."); _callback(new List <Friend>()); } }
private void OnFriendsRequest(Datagram datagram) { FriendGroupApplyRequest request = datagram.UnSerialData <FriendGroupApplyRequest>(); FriendsResponse response = new FriendsResponse { FriendsID = UserInfoReader.ReadFriends(request.UserID) }; datagram.DataType = DatagramType.Client; datagram.MessageType = LoginMessageType.FriendsResponse; datagram.Datas = response.ToByteArray(); if (!Send(datagram.ToByteArray())) { Notify(IKXTServer.LogLevel.Error, "数据发送异常"); Close(); } }
public async Task <FriendsResponse> GetFriends(int limit = 20, int offset = 0) { if (string.IsNullOrEmpty(UserId)) { // If UserId hasn't been loaded yet then retrieve it MeResponse me = await GetMe(); UserId = me.Data !.User.Id; } Url url = new Url(BaseUrl).AppendPathSegments("users", UserId, "friends") .SetQueryParams(new { limit = limit, offset = offset, access_token = AccessToken }); HttpResponseMessage responseMessage = await Get(url); FriendsResponse response = GetObject <FriendsResponse>(await responseMessage.Content.ReadAsStringAsync()); return(response); }
public async Task InvokeWithNullFriendsReturnsNull() { // Arrange var appSettings = new AppSettings { Splitwise = new Splitwise { ConsumerKey = "consumerKey", ConsumerSecret = "consumerSecret", FriendEmail = "friendEmail", TransactionsDatedAfter = new DateTimeOffset() }, Ynab = new Ynab { PersonalAccessToken = "personalAccessToken", BudgetName = "budgetName", SplitwiseAccountName = "splitwiseAccountName" } }; var expectedUser = new CurrentUserResponse { User = new User { Id = 1, FirstName = "firstName" } }; _splitwiseClient.GetCurrentUser().Returns(expectedUser); var expectedFriends = new FriendsResponse(); _splitwiseClient.GetFriends().Returns(expectedFriends); // Act _sut = new GetSplitwiseInfoOperation(_logger, _splitwiseClient); var result = await _sut.Invoke(appSettings); // Assert Assert.Null(result); }