public void TestDeleteObjectObjectId() { ClearTest(); _indexHelper = new IndexHelper <TestModel>(_client, GetSafeName("àlgol?à-csharp"), "TestModelId"); var model = BuildTestModel(); var task = _indexHelper.SaveObject(model); _indexHelper.WaitTask(task["taskID"].ToString()); var models = BuildTestModelList(); var tasks = _indexHelper.SaveObjects(models); foreach (var item in tasks) { _indexHelper.WaitTask(item["taskID"].ToString()); } var res = _indexHelper.Search(new Query("")); Assert.Equal(5, res["nbHits"].ToObject <int>()); Assert.Equal("Sylvain", res["hits"][0]["FirstName"].ToString()); Assert.Equal("8", res["hits"][0]["objectID"].ToString()); task = _indexHelper.DeleteObject(model); _indexHelper.WaitTask(task["taskID"].ToString()); res = _indexHelper.Search(new Query("")); Assert.Equal(4, res["nbHits"].ToObject <int>()); Assert.Equal("Sylvain", res["hits"][0]["FirstName"].ToString()); Assert.Equal("8", res["hits"][0]["objectID"].ToString()); }
public void TestDeleteObjectObjectId() { ClearTest(); _indexHelper = new IndexHelper<TestModel>(_client, GetSafeName("àlgol?à-csharp"), "TestModelId"); var model = BuildTestModel(); var task = _indexHelper.SaveObject(model); _indexHelper.WaitTask(task["taskID"].ToString()); var models = BuildTestModelList(); var tasks = _indexHelper.SaveObjects(models); foreach (var item in tasks) { _indexHelper.WaitTask(item["taskID"].ToString()); } var res = _indexHelper.Search(new Query("")); Assert.AreEqual(5, res["nbHits"].ToObject<int>()); Assert.AreEqual("Sylvain", res["hits"][0]["FirstName"].ToString()); Assert.AreEqual("8", res["hits"][0]["objectID"].ToString()); task = _indexHelper.DeleteObject(model); _indexHelper.WaitTask(task["taskID"].ToString()); res = _indexHelper.Search(new Query("")); Assert.AreEqual(4, res["nbHits"].ToObject<int>()); Assert.AreEqual("Sylvain", res["hits"][0]["FirstName"].ToString()); Assert.AreEqual("8", res["hits"][0]["objectID"].ToString()); }