public void TestDnsTimeout()
        {
            var hosts = new List <string> {
                _testApplicationID + "-dsn.algolia.biz",
                _testApplicationID + "-dsn.algolia.net",
                _testApplicationID + "-1.algolianet.com",
                _testApplicationID + "-2.algolianet.com",
                _testApplicationID + "-3.algolianet.com"
            };

            var _client = new AlgoliaClient(_testApplicationID, _testApiKey, hosts);

            _client.setTimeout(0.5, 0.5);
            var startTime = DateTime.Now;
            var index     = _client.ListIndexes();

            Assert.IsTrue(startTime.AddSeconds(0.5) < DateTime.Now);
        }
 public void TestTimeoutHandling()
 {
     _client.setTimeout(0.001, 0.001);
     try
     {
         _client.ListIndexes();
         _client = new AlgoliaClient(_testApplicationID, _testApiKey);
         _index  = _client.InitIndex(safe_name("àlgol?à-csharp"));
         Assert.Fail("Should throw an error");
     }
     catch (AlgoliaException)
     {
         // Reset
         _client = new AlgoliaClient(_testApplicationID, _testApiKey);
         _index  = _client.InitIndex(safe_name("àlgol?à-csharp"));
     }
     catch (OperationCanceledException)
     {
         _client = new AlgoliaClient(_testApplicationID, _testApiKey);
         _index  = _client.InitIndex(safe_name("àlgol?à-csharp"));
         Assert.Fail("Should throw an AlgoliaException");
     }
 }