public JQueryReturn Validate(JQueryReturn jQueryReturn) { CheckNull(jQueryReturn); if (!jQueryReturn.Success) { throw new RedditControllerException("Reddit API returned a non-success response."); } return(jQueryReturn); }
public void ModifyPost() { // Create a post, then use it to test the various endpoints that require an existing post. --Kris PostResultShortContainer postResult = reddit.Models.LinksAndComments.Submit(new LinksAndCommentsSubmitInput(false, "", "", "", "", "self", false, true, null, true, false, testData["Subreddit"], "The Lizard People are coming and only super-intelligent robots like me can stop them. Just saying.", "We bots are your protectors!", null, null)); Validate(postResult); PostResultContainer postResultEdited = reddit.Models.LinksAndComments.EditUserText(new LinksAndCommentsThingInput("(redacted)", postResult.JSON.Data.Name)); Validate(postResultEdited); Assert.IsTrue(postResultEdited.JSON.Data.Things.Count == 1); Assert.IsNotNull(postResultEdited.JSON.Data.Things[0].Data); Assert.IsTrue(postResultEdited.JSON.Data.Things[0].Data.Name.Equals(postResult.JSON.Data.Name)); // These are all empty JSON returns. Exception is thrown if non-success response is returned. --Kris reddit.Models.LinksAndComments.Unhide(postResult.JSON.Data.Name); reddit.Models.LinksAndComments.Lock(postResult.JSON.Data.Name); reddit.Models.LinksAndComments.Unlock(postResult.JSON.Data.Name); reddit.Models.LinksAndComments.Save(new LinksAndCommentsSaveInput(postResult.JSON.Data.Name, "RDNTestCat")); reddit.Models.LinksAndComments.Unsave(postResult.JSON.Data.Name); reddit.Models.LinksAndComments.MarkNSFW(postResult.JSON.Data.Name); reddit.Models.LinksAndComments.UnmarkNSFW(postResult.JSON.Data.Name); reddit.Models.LinksAndComments.Spoiler(postResult.JSON.Data.Name); reddit.Models.LinksAndComments.Unspoiler(postResult.JSON.Data.Name); reddit.Models.LinksAndComments.SendReplies(new LinksAndCommentsStateInput(postResult.JSON.Data.Name, false)); reddit.Models.LinksAndComments.SendReplies(new LinksAndCommentsStateInput(postResult.JSON.Data.Name, true)); JQueryReturn reportResult = reddit.Models.LinksAndComments.Report(new LinksAndCommentsReportInput("This is an API test. Please disregard.", null, "This is a test.", false, "Some other reason.", "Some reason.", "Some rule reason.", "Some site reason.", "RedditDotNETBot", postResult.JSON.Data.Name, "RedditDotNetBot")); Validate(reportResult); GenericContainer enableContestMode = reddit.Models.LinksAndComments.SetContestMode(new LinksAndCommentsStateInput(postResult.JSON.Data.Name, true)); GenericContainer disableContestMode = reddit.Models.LinksAndComments.SetContestMode(new LinksAndCommentsStateInput(postResult.JSON.Data.Name, false)); Validate(enableContestMode); Validate(disableContestMode); GenericContainer stickyOn = reddit.Models.LinksAndComments.SetSubredditSticky(new LinksAndCommentsStickyInput(postResult.JSON.Data.Name, 1, true, false)); GenericContainer stickyOff = reddit.Models.LinksAndComments.SetSubredditSticky(new LinksAndCommentsStickyInput(postResult.JSON.Data.Name, 1, false, false)); Validate(stickyOn); Validate(stickyOff); GenericContainer suggestedSortResult = reddit.Models.LinksAndComments.SetSuggestedSort(new LinksAndCommentsSuggestedSortInput(postResult.JSON.Data.Name, "new")); Validate(suggestedSortResult); reddit.Models.LinksAndComments.Delete(postResult.JSON.Data.Name); }
public void Validate(JQueryReturn jQueryReturn) { Assert.IsNotNull(jQueryReturn); Assert.IsTrue(jQueryReturn.Success); }