public async Task GetSubmission() { var client = new PsawClient(); var submmissions = await client.Search <SubmissionEntry>(new SearchOptions { Subreddit = "game", Size = 1 }); Assert.Single(submmissions); }
public async Task GetComments() { var client = new PsawClient(); var comments = await client.Search <CommentEntry>(new SearchOptions { Subreddit = "game", Size = 500 }); Assert.Equal(500, comments.Length); Assert.True(comments.All(c => c.Subreddit == "game")); }
public async Task GetSubmissions() { var client = new PsawClient(); var submmissions = await client.Search <SubmissionEntry>(new SearchOptions { Subreddit = "game", Size = 1000 }); Assert.Equal(1000, submmissions.Length); Assert.DoesNotContain(submmissions.GroupBy(s => s.Id), g => g.Count() > 1); }
public async Task GetSubmissionComments() { const string submissionId = "a2df38"; var client = new PsawClient(); var commentIds = (await client.GetSubmissionCommentIds(submissionId)).Take(500).ToArray(); // Only taking 500 because more would result in a [Request Line is too large (8039 > 4094)] error var comments = await client.Search <CommentEntry>(new SearchOptions { Ids = commentIds }); Assert.Equal(500, comments.Length); }
public async Task RateLimit() { var client = new PsawClient(); var options = new SearchOptions { Subreddit = "game", Size = 1 }; var sw = Stopwatch.StartNew(); for (int i = 0; i < 180; i++) { await client.Search <SubmissionEntry>(options); _output.WriteLine(i + " done in " + sw.Elapsed.TotalMilliseconds); } // 180 requests should end in more than 2 minutes Assert.True(sw.Elapsed.TotalSeconds > 120); }