コード例 #1
0
 public void SubmitChat_ChatCanBeRetrieved()
 {
     Chat chat = new Chat("Visual Studio unit testing chat submission.");
     Assert.IsTrue(chat.Submit());
     currentUser.Chats = new Chats(CurrentUser.Id);
     Chat retrievedChat = currentUser.Chats.ChatCollection[0];
     Assert.AreEqual(chat.Content, retrievedChat.Content);
 }
コード例 #2
0
 private void ParseChat(JObject joChat)
 {
     Chat chat = new Chat();
     chat.ChatId = joChat.ParseJsonInt("id");
     chat.UserId = joChat.ParseJsonInt("user_id");
     chat.Content = joChat.ParseJsonString("content");
     chat.CreatedAt = joChat.ParseJsonDateTime("created_at");
     chat.UpdatedAt = joChat.ParseJsonDateTime("updated_at");
     chat.PictureFileName = (joChat.SelectToken("picture") as JObject).ParseJsonString("url");
     ChatCollection.Add(chat);
 }
コード例 #3
0
        private void ParseChat(JObject joChat)
        {
            Chat chat = new Chat();
            chat.ChatId = joChat.ParseJsonInt("id");
            chat.UserId = joChat.ParseJsonInt("user_id");
            chat.Content = joChat.ParseJsonString("content");
            chat.CreatedAt = joChat.ParseJsonDateTime("created_at");
            chat.UpdatedAt = joChat.ParseJsonDateTime("updated_at");
            chat.PictureFileName = (joChat.SelectToken("picture") as JObject).ParseJsonString("url");

            if (chat.UserId != CurrentUser.Id)
            {
                chat.UserName = Relationships.Followers.Concat(Relationships.Following).Where(u => u.Id == chat.UserId).First().Name;
                chat.UserGravatarUrl = Relationships.Followers.Concat(Relationships.Following).Where(u => u.Id == chat.UserId).First().GravatarUrl;
            }
            else
            {
                chat.UserName = CurrentUser.Name;
                chat.UserGravatarUrl = CurrentUser.GravatarUrl;
            }
            ChatCollection.Add(chat);
        }