public void BadClientCreation() { string[] _hosts = new string[] { "localhost.algolia.com:8080", "" }; try { new AlgoliaClient("", _testApiKey); Assert.Fail(); } catch (Exception) { } try { new AlgoliaClient(_testApplicationID, ""); Assert.Fail(); } catch (Exception) { } try { new AlgoliaClient(_testApplicationID, "", _hosts); Assert.Fail(); } catch (Exception) { } try { new AlgoliaClient("", _testApiKey, _hosts); Assert.Fail(); } catch (Exception) { } try { var badClient = new AlgoliaClient(_testApplicationID, _testApiKey, null); Assert.Fail(); } catch (Exception) { } try { var badClient = new AlgoliaClient(_testApplicationID, _testApiKey, _hosts); badClient.ListIndexes(); Assert.Fail(); } catch (Exception) { } }
public void TestClientWithMock() { var client = new AlgoliaClient("test", "test", null, getEmptyHandler()); Assert.AreEqual(JObject.Parse("{\"items\":[]}").ToString(), client.ListIndexes().ToString()); Assert.AreEqual(JObject.Parse("{\"results\":[]}").ToString(), client.InitIndex("{indexName}").GetObjects(new string[] { "myID" }).ToString()); }