Exemplo n.º 1
0
        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
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        public async Task GetProjectsLimit()
        {
            IPlanGridApi   client = PlanGridClient.Create();
            Page <Project> page   = await client.GetProjects(limit : 1);

            Assert.AreEqual(1, page.Data.Length);
        }
Exemplo n.º 4
0
        public async Task GetProjectsTotalCount()
        {
            IPlanGridApi   client = PlanGridClient.Create();
            Page <Project> page   = await client.GetProjects();

            Assert.AreEqual(3, page.TotalCount);
        }