/// <summary> /// Tests the WaitAndRun function with a QuotaGrate and the bucketed API endpoint. /// </summary> /// <returns>Whether or not the test was successful along with the response.</returns> private static TestResult TestWaitAndRun() { const int bucketSize = 5; const int expirationTime = 5000; var getRoute = $"/ratetest/get/bucketed/TestWaitAndRun/{bucketSize}/{expirationTime}"; var evalRoute = $"/ratetest/eval/bucketed/TestWaitAndRun/{bucketSize}/{expirationTime}"; var clearRoute = $"/ratetest/clear/bucketed/TestWaitAndRun/{bucketSize}/{expirationTime}"; Get(clearRoute); var grate = new QuotaGrate<string>(bucketSize, TimeSpan.FromMilliseconds(expirationTime)); var token = "demoToken"; for (var i = 0; i < 10; i++) { grate.WaitAndRun(token, new Task<string>(() => Get(getRoute))).Wait(); } // @todo timing check here return GetAsBool(evalRoute); }