public async Task HitRateLimit() { IPlanGridApi client = PlanGridClient.Create(TestData.RateLimitedPlanGridApiKey); try { await client.GetProjects(); } catch { // The rate limit for this user is 1 per day. So the first one might succeed, or it might not. } try { await client.GetProjects(); Assert.Fail("Should have exceeded the rate limit"); } catch (RateLimitExceededException ex) { Assert.AreEqual(1, ex.RateLimit.Limit); Assert.AreEqual(0, ex.RateLimit.Remaining); Assert.AreEqual(RequestType.All, ex.RateLimit.RequestType); Assert.AreNotEqual(DateTime.MinValue, ex.RateLimit.Reset); Assert.AreEqual(86400, ex.RateLimit.Interval); // 1 day } }
public async Task GetProjectsOffset() { IPlanGridApi client = PlanGridClient.Create(); Page <Project> page = await client.GetProjects(); string secondProjectUid = page.Data[1].Uid; page = await client.GetProjects(1); Assert.AreEqual(secondProjectUid, page.Data.First().Uid); }
public async Task GetProjectsLimit() { IPlanGridApi client = PlanGridClient.Create(); Page <Project> page = await client.GetProjects(limit : 1); Assert.AreEqual(1, page.Data.Length); }
public async Task GetProjectsTotalCount() { IPlanGridApi client = PlanGridClient.Create(); Page <Project> page = await client.GetProjects(); Assert.AreEqual(3, page.TotalCount); }