void FilterRequests(IHttpRequest request, IHttpResponse response, object requestObject)
        {
            string userName = request.Headers.Get("Username");
            string apiKey   = request.Headers.Get("ApiKey");

            if (String.IsNullOrEmpty(userName))
            {
                throw new Exception("Please suply username in 'Username' header");
            }

            if (String.IsNullOrEmpty(apiKey))
            {
                throw new Exception("Please suply API key in 'ApiKey' header");
            }

            if (!QuotaProvider.AuthenticateUser(userName, apiKey))
            {
                throw new Exception("Invalid user or API key");
            }

            int quotaAmount = QuotaProvider.GetHourlyQuota(userName);

            if (quotaAmount >= 0)
            {
                int currentUsage = UsageStorer.GetCurrentUsage(userName);

                //Increment for each API call
                currentUsage++;

                if (currentUsage > quotaAmount)
                {
                    throw new Exception("You have exceded your quota!");
                }

                UsageStorer.StoreNewUsage(userName, currentUsage);
            }
        }
 public void GetHourlyQuotaTest()
 {
     Assert.AreEqual(10, provider.GetHourlyQuota("User01"));
     Assert.AreEqual(20, provider.GetHourlyQuota("UpgradedUser01"));
     Assert.AreEqual(-1, provider.GetHourlyQuota("Admin"));
 }