public void setup() { DBName = "httphelpertests" + DateTime.Now.Ticks; baseUri = new Uri(string.Format(@"https://{0}.cloudant.com/", TestConstants.account)); helper = new HttpHelper(baseUri); helper.AddGlobalHeader("Authorization", "Basic " + Convert.ToBase64String(System.Text.UTF8Encoding.UTF8.GetBytes(TestConstants.username + ":" + TestConstants.password))); }
// ======== PRIVATE HELPERS ============= private void InitHttpHelper(List<IHttpConnectionInterceptor> interceptors) { if (interceptors != null) { List<IHttpConnectionRequestInterceptor> requestInterceptors = new List<IHttpConnectionRequestInterceptor>(); List<IHttpConnectionResponseInterceptor> responseInterceptors = new List<IHttpConnectionResponseInterceptor>(); foreach (IHttpConnectionInterceptor httpConnInterceptor in interceptors) { if (httpConnInterceptor == null || !(httpConnInterceptor is IHttpConnectionRequestInterceptor || httpConnInterceptor is IHttpConnectionResponseInterceptor)) throw new DataException(DataException.Configuration_InvalidHttpInterceptor, string.Format("Http interceptors must implement either IHttpConnectionRequestInterceptor or " + "IHttpConnectionResponseInterceptor interfaces. Class {0} doesn't implement either if these interfaces.", httpConnInterceptor.GetType())); if (httpConnInterceptor is IHttpConnectionRequestInterceptor) requestInterceptors.Add(httpConnInterceptor as IHttpConnectionRequestInterceptor); if (httpConnInterceptor is IHttpConnectionResponseInterceptor) responseInterceptors.Add(httpConnInterceptor as IHttpConnectionResponseInterceptor); } httpHelper = new HttpHelper(accountUri, requestInterceptors, responseInterceptors); } else { httpHelper = new HttpHelper(accountUri); } }