public void MessageReply() { User me = reddit.Models.Account.Me(); User patsy = GetTargetUserModel(); // Create the initial message. --Kris reddit.Models.PrivateMessages.Compose(new PrivateMessagesComposeInput(subject: "Test Message", text: "This is a test. So there.", to: patsy.Name)); // Wait until the message arrives, then grab it. The message ID is not returned by the Compose endpoint. --Kris DateTime start = DateTime.Now; MessageContainer messages = null; while (start.AddMinutes(2) >= DateTime.Now && GetTestMessage(out messages, me.Name) == null) { Thread.Sleep(1500); } Message message = GetTestMessage(messages, me.Name); Assert.IsNotNull(message); // If this fails, it likely means that the test message has not yet arrived or one test user is blocking the other. --Kris // Now that we have our initial test message, let's reply to it. --Kris CommentResultContainer commentResultContainer = reddit2.Models.LinksAndComments.Comment(new LinksAndCommentsThingInput("Message received.", message.Name)); Validate(commentResultContainer); }
public void Validate(CommentResultContainer commentResultContainer) { Assert.IsNotNull(commentResultContainer); Assert.IsNotNull(commentResultContainer.JSON); Assert.IsNotNull(commentResultContainer.JSON.Data); Assert.IsNotNull(commentResultContainer.JSON.Data.Things); Assert.IsTrue(commentResultContainer.JSON.Data.Things.Count > 0); Assert.IsNotNull(commentResultContainer.JSON.Data.Things[0].Data); }
public void Remove() { PostResultShortContainer postResult = TestPost(); Validate(postResult); CommentResultContainer commentResult = TestComment(postResult.JSON.Data.Name); Validate(commentResult); reddit.Models.Moderation.Remove(new ModerationRemoveInput(postResult.JSON.Data.Name)); reddit.Models.Moderation.Remove(new ModerationRemoveInput(commentResult.JSON.Data.Things[0].Data.Name)); }
public void PostAndComment() { PostResultShortContainer postResult = TestPost(); Validate(postResult); CommentResultContainer commentResult = TestComment(postResult.JSON.Data.Name); Validate(commentResult); CommentResultContainer commentResult2 = TestCommentReply(commentResult.JSON.Data.Things[0].Data.Name); Validate(commentResult2); }
public void IgnoreReports() { PostResultShortContainer postResult = TestPost(); Validate(postResult); CommentResultContainer commentResult = TestComment(postResult.JSON.Data.Name); Validate(commentResult); reddit.Models.Moderation.IgnoreReports(postResult.JSON.Data.Name); reddit.Models.Moderation.IgnoreReports(commentResult.JSON.Data.Things[0].Data.Name); reddit.Models.Moderation.UnignoreReports(postResult.JSON.Data.Name); reddit.Models.Moderation.UnignoreReports(commentResult.JSON.Data.Things[0].Data.Name); }
public List <Comment> GetComments(CommentResultContainer commentContainer, Dispatch dispatch) { if (commentContainer == null || commentContainer.JSON == null || commentContainer.JSON.Data == null || commentContainer.JSON.Data.Things == null) { return(null); } List <Comment> comments = new List <Comment>(); foreach (CommentChild commentChild in commentContainer.JSON.Data.Things) { if (commentChild.Data != null) { comments.Add(new Comment(dispatch, commentChild.Data)); } } return(comments); }
public void Distinguish() { PostResultShortContainer postResult = TestPost(); Validate(postResult); CommentResultContainer commentResult = TestComment(postResult.JSON.Data.Name); Validate(commentResult); PostResultContainer post = reddit.Models.Moderation.DistinguishPost("yes", postResult.JSON.Data.Name); CommentResultContainer comment = reddit.Models.Moderation.DistinguishComment("yes", commentResult.JSON.Data.Things[0].Data.Name, true); Validate(post); Assert.AreEqual(postResult.JSON.Data.Name, post.JSON.Data.Things[0].Data.Name); Assert.AreEqual("moderator", post.JSON.Data.Things[0].Data.Distinguished); Validate(comment); Assert.AreEqual(commentResult.JSON.Data.Things[0].Data.Name, comment.JSON.Data.Things[0].Data.Name); Assert.AreEqual("moderator", comment.JSON.Data.Things[0].Data.Distinguished); Assert.IsTrue(comment.JSON.Data.Things[0].Data.Stickied); }