Beispiel #1
0
 public void TestParseFriendWall()
 {
     string input = "{\"response\":[258,{\"id\":2300,\"from_id\":2760562,\"to_id\":2760562}]}";
       //  "{\"response\":[258,{\"id\":2300,\"from_id\":2760562,\"to_id\":2760562}]}"
     FriendWall userListActual = MyParseJSON.ParseFriendWall(input);
     FriendWall eList = new FriendWall();
     eList.count = 258;
     eList.postList.Add(new Post());
     eList.postList[0].from_id = 2760562;
     eList.postList[0].to_id = 2760562;
     Debug.Assert(userListActual != null, "userListActual != null");
     Assert.AreEqual(expected: eList.postList[0].from_id, actual: userListActual.postList[0].from_id);
     Assert.AreEqual(expected: eList.postList[0].to_id, actual: userListActual.postList[0].to_id);
     //
     // TODO: добавьте здесь логику теста
     //
 }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            FriendList friendList = MyParseJSON.ParseFriendList(VkChaterer.GetFriends(_userId));

            //находим самого активного друга по постам
            foreach (FriendResponse response in friendList.response)
            {
                FriendWall friendWall = MyParseJSON.ParseFriendWall(VkChaterer.GetPosts(response.user_id));
                friendWall.user_id = response.user_id;
                if (_max < friendWall.count)
                {
                    _max = friendWall.count;
                    _mostActiveFriendId = friendWall.user_id;
                }
            }
            _answer = new Form2(_mostActiveFriendId, _max);
            _answer.Show();
        }
Beispiel #3
0
        public static FriendWall ParseFriendWall(string jsonWall)
        {
            JArray     array      = CreateArray(jsonWall);
            FriendWall friendWall = new FriendWall();

            try
            {
                friendWall.count = Int16.Parse(array.First().ToString());
                foreach (JObject content in array.Children <JObject>())
                {
                    friendWall.postList.Add(JsonConvert.DeserializeObject <Post>(content.ToString()));
                }
            }
            catch (Exception exception)
            {
                // MessageBox.Show(exception.ToString());
            }
            return(friendWall);
        }
        public static FriendWall ParseFriendWall(string jsonWall)
        {
            JArray array = CreateArray(jsonWall);
            FriendWall friendWall = new FriendWall();
            try
            {
                friendWall.count = Int16.Parse(array.First().ToString());
                foreach (JObject content in array.Children<JObject>())
                {

                    friendWall.postList.Add(JsonConvert.DeserializeObject<Post>(content.ToString()));
                }
            }
            catch(Exception exception)
            {

               // MessageBox.Show(exception.ToString());

            }
               return friendWall;
        }