Beispiel #1
0
        /// <summary>
        /// Initializes type instance
        /// </summary>
        /// <param name="comment">Comment object</param>
        internal Comment(SOAPComment comment)
        {
            AvatarUrl = comment.avatar_url;
            ID = comment.comment_id;
            CreatedOn = UnixTimeConverter.Instance.FromUnixTime(comment.created);
            Text = comment.message;
            UserID = comment.user_id;
            UserName = comment.user_name;

            _replyComments.AddRange(ConvertReplyComments(comment.reply_comments));
        }
Beispiel #2
0
        private static IList<Comment> ConvertReplyComments(SOAPComment[] comments)
        {
            List<Comment> result = new List<Comment>();

            if (comments != null)
            {
                for (int i = 0; i < comments.Length; i++)
                {
                    result.Add(new Comment(comments[i]));
                }
            }

            return result;
        }
        public void TestConstructor()
        {
            DateTime parentCommentCreatedOn = new DateTime(2010, 1, 1, 2, 3, 4);
            const string parentCommentAvatarUrl = "http://jdhfgbsdjh.jdh";
            const long parentCommentID = 36756327;
            const string parentCommentMessage = "ksjdvbsdjkbgvksdjbvgsldk usgis gygfawekl gwieaugw29375293#$%^&";
            const long parentCommentUserID = 723648;
            const string parentCommentUserName = "******";

            DateTime childCommentCreatedOn = new DateTime(2010, 3, 5, 5, 3, 4);
            const string childCommentAvatarUrl = "http://kjdfgblsdlsfkn.jdh";
            const long childCommentID = 5234216543;
            const string childCommentMessage = "ieurgt834q7t34nv 34t 4ty 34p8t 34qt";
            const long childCommentUserID = 2389529873;
            const string childCommentUserName = "******";

            DateTime grandChildCommentCreatedOn = new DateTime(2010, 9, 5, 9, 3, 9);
            const string grandChildCommentAvatarUrl = "http://skdgbdskb.jdh";
            const long grandChildCommentID = 12541;
            const string grandChildCommentMessage = "ылдкпоиыл";
            const long grandChildCommentUserID = 346346;
            const string grandChildCommentUserName = "******";

            SOAPComment parentSoapComment = new SOAPComment
                                      	{
                                      		avatar_url = parentCommentAvatarUrl,
                                      		comment_id = parentCommentID,
                                      		created = (long) UnixTimeConverter.Instance.ToUnixTime(parentCommentCreatedOn),
                                      		message = parentCommentMessage,
                                      		user_id = parentCommentUserID,
                                      		user_name = parentCommentUserName
                                      	};

            SOAPComment childSoapComment = new SOAPComment
                                           	{
                                                avatar_url = childCommentAvatarUrl,
                                                comment_id = childCommentID,
                                                created = (long)UnixTimeConverter.Instance.ToUnixTime(childCommentCreatedOn),
                                                message = childCommentMessage,
                                                user_id = childCommentUserID,
                                                user_name = childCommentUserName
                                           	};

            SOAPComment grandChildSoapComment = new SOAPComment
                                                    {
                                                        avatar_url = grandChildCommentAvatarUrl,
                                                        comment_id = grandChildCommentID,
                                                        created = (long)UnixTimeConverter.Instance.ToUnixTime(grandChildCommentCreatedOn),
                                                        message = grandChildCommentMessage,
                                                        user_id = grandChildCommentUserID,
                                                        user_name = grandChildCommentUserName
                                                    };

            parentSoapComment.reply_comments = new[] {childSoapComment};
            childSoapComment.reply_comments = new[] { grandChildSoapComment };

            Comment comment = new Comment(parentSoapComment);

            Assert.AreEqual(parentCommentID, comment.ID);
            Assert.AreEqual(parentCommentUserID, comment.UserID);
            Assert.AreEqual(parentCommentCreatedOn, comment.CreatedOn);

            StringAssert.AreEqualIgnoringCase(parentCommentAvatarUrl, comment.AvatarUrl);
            StringAssert.AreEqualIgnoringCase(parentCommentMessage, comment.Text);
            StringAssert.AreEqualIgnoringCase(parentCommentUserName, comment.UserName);

            Assert.AreEqual(1, comment.ReplyComments.Count);

            Assert.AreEqual(childCommentID, comment.ReplyComments[0].ID);
            Assert.AreEqual(childCommentUserID, comment.ReplyComments[0].UserID);
            Assert.AreEqual(childCommentCreatedOn, comment.ReplyComments[0].CreatedOn);

            StringAssert.AreEqualIgnoringCase(childCommentAvatarUrl, comment.ReplyComments[0].AvatarUrl);
            StringAssert.AreEqualIgnoringCase(childCommentMessage, comment.ReplyComments[0].Text);
            StringAssert.AreEqualIgnoringCase(childCommentUserName, comment.ReplyComments[0].UserName);

            Assert.AreEqual(1, comment.ReplyComments[0].ReplyComments.Count);

            Assert.AreEqual(grandChildCommentID, comment.ReplyComments[0].ReplyComments[0].ID);
            Assert.AreEqual(grandChildCommentUserID, comment.ReplyComments[0].ReplyComments[0].UserID);
            Assert.AreEqual(grandChildCommentCreatedOn, comment.ReplyComments[0].ReplyComments[0].CreatedOn);

            StringAssert.AreEqualIgnoringCase(grandChildCommentAvatarUrl, comment.ReplyComments[0].ReplyComments[0].AvatarUrl);
            StringAssert.AreEqualIgnoringCase(grandChildCommentMessage, comment.ReplyComments[0].ReplyComments[0].Text);
            StringAssert.AreEqualIgnoringCase(grandChildCommentUserName, comment.ReplyComments[0].ReplyComments[0].UserName);

            Assert.AreEqual(0, comment.ReplyComments[0].ReplyComments[0].ReplyComments.Count);
        }
 /// <remarks/>
 public string Endget_comments(System.IAsyncResult asyncResult, out SOAPComment[] comments)
 {
     object[] results = this.EndInvoke(asyncResult);
     comments = ((SOAPComment[])(results[1]));
     return ((string)(results[0]));
 }
 /// <remarks/>
 public string Endadd_comment(System.IAsyncResult asyncResult, out SOAPComment comment)
 {
     object[] results = this.EndInvoke(asyncResult);
     comment = ((SOAPComment)(results[1]));
     return ((string)(results[0]));
 }
 public string add_comment(string api_key, string auth_token, long target_id, string target, string message, out SOAPComment comment)
 {
     object[] results = this.Invoke("add_comment", new object[] {
                 api_key,
                 auth_token,
                 target_id,
                 target,
                 message});
     comment = ((SOAPComment)(results[1]));
     return ((string)(results[0]));
 }
 public string get_comments(string api_key, string auth_token, long target_id, string target, out SOAPComment[] comments)
 {
     object[] results = this.Invoke("get_comments", new object[] {
                 api_key,
                 auth_token,
                 target_id,
                 target});
     comments = ((SOAPComment[])(results[1]));
     return ((string)(results[0]));
 }